Browse Source

Conserta teste do crispy layout mixin

pull/520/head
Marcio Mazza 9 years ago
parent
commit
064c1c4c9f
  1. 1
      sapl/crispy_layout_mixin.py
  2. 33
      sapl/test_crispy_layout_mixin.py

1
sapl/crispy_layout_mixin.py

@ -145,7 +145,6 @@ class CrispyLayoutFormMixin:
def read_yaml_from_file(yaml_layout): def read_yaml_from_file(yaml_layout):
# TODO cache this at application level # TODO cache this at application level
t = template.loader.get_template(yaml_layout) t = template.loader.get_template(yaml_layout)
rendered = t.render() rendered = t.render()

33
sapl/test_crispy_layout_mixin.py

@ -1,9 +1,13 @@
from unittest import mock
import rtyaml
from sapl.crispy_layout_mixin import read_layout_from_yaml from sapl.crispy_layout_mixin import read_layout_from_yaml
def test_read_layout_from_yaml(tmpdir): def test_read_layout_from_yaml(tmpdir):
contents = ''' stub_content = '''
ModelName: ModelName:
Cool Legend: Cool Legend:
- name:9 place tiny - name:9 place tiny
@ -12,18 +16,17 @@ ModelName:
More data: More data:
- equalA equalB equalC - equalA equalB equalC
- highlander ''' - highlander '''
file = tmpdir.join('zzz.yaml')
file.write(contents)
expected = [ with mock.patch('sapl.crispy_layout_mixin.read_yaml_from_file') as ryff:
['Cool Legend', ryff.return_value = rtyaml.load(stub_content)
[('name', 9), ('place', 2), ('tiny', 1)], assert read_layout_from_yaml('....', 'ModelName') == [
[('field', 10), ('nature', 2)], ['Cool Legend',
[('kind', 1), ('date', 3), ('unit', 5), ('status', 3)], [('name', 9), ('place', 2), ('tiny', 1)],
], [('field', 10), ('nature', 2)],
['More data', [('kind', 1), ('date', 3), ('unit', 5), ('status', 3)],
[('equalA', 4), ('equalB', 4), ('equalC', 4)], ],
[('highlander', 12)], ['More data',
], [('equalA', 4), ('equalB', 4), ('equalC', 4)],
] [('highlander', 12)],
assert read_layout_from_yaml(file.strpath, 'ModelName') == expected ],
]

Loading…
Cancel
Save