File: 003_fields.py

package info (click to toggle)
python-django-crispy-forms-foundation 1.1.0%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 880 kB
  • sloc: javascript: 6,437; python: 1,326; makefile: 200; sh: 17
file content (65 lines) | stat: -rw-r--r-- 2,236 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import os

from django.test.html import parse_html
from crispy_forms_foundation.layout import (Layout, InlineField,
                                            InlineSwitchField, FakeField)

from tests.forms import BasicInputForm, BoolInputForm
# from tests.utils import write_output


def test_fakefield(output_test_path, render_output, rendered_template,
                   helper, client):
    form = BasicInputForm()
    pack = helper.template_pack

    helper.layout = Layout(
        FakeField('simple')
    )

    rendered = rendered_template(form, helper=helper)

    attempted = render_output(os.path.join(output_test_path, pack,
                                           "test_fakefield.html"))
    # write_output(output_test_path, pack, "test_fakefield.html", rendered)

    assert parse_html(attempted) == parse_html(rendered)


def test_inlinefield(output_test_path, render_output, rendered_template,
                     helper, client):
    form = BasicInputForm()
    pack = helper.template_pack

    helper.layout = Layout(
        InlineField('simple', label_column='large-7', input_column='large-5',
                    label_class='foobar')
    )

    rendered = rendered_template(form, helper=helper)

    attempted = render_output(os.path.join(output_test_path, pack,
                                           "test_inlinefield.html"))
    # write_output(output_test_path, pack, "test_inlinefield.html", rendered)

    assert parse_html(attempted) == parse_html(rendered)


def test_inlineswitchfield(output_test_path, render_output, rendered_template,
                           helper, client):
    form = BoolInputForm()
    pack = helper.template_pack

    helper.layout = Layout(
        InlineSwitchField('opt_in', label_column='large-8',
                          input_column='large-4', label_class='foobar',
                          switch_class="inline")
    )

    rendered = rendered_template(form, helper=helper)

    attempted = render_output(os.path.join(output_test_path, pack,
                                           "test_inlineswitchfield.html"))
    # write_output(output_test_path, pack, "test_inlineswitchfield.html", rendered)

    assert parse_html(attempted) == parse_html(rendered)