def testGetRenderedFieldsCorrect(self): fields = [ String('test_string', name='field1'), If(Equal('test_group_5', 'A'), String('if', name='if_field3'), name='if2'), IfNot(Equal('test_group_5', 'A'), String('ifnot', name='ifnot_field5'), name='ifnot4'), Group(name='test_group_5', values=['A', 'B', 'C']) ] container = self.get_default_container(fields) expected_list = filter(lambda x: len(x.render()), fields) if len(container.render()): self.assertListEqual(container.get_rendered_fields(), expected_list) else: self.assertListEqual(container.get_rendered_fields(), []) while container.mutate(): expected_list = filter(lambda x: len(x.render()), fields) if len(container.render()): self.assertEqual(container.get_rendered_fields(), expected_list) else: self.assertEqual(container.get_rendered_fields(), [])
def testCopy(self): fields = [ String('test_string', name='field1'), If(Equal('test_group_5', 'A'), String('if', name='if_field3'), name='if2'), IfNot(Equal('test_group_5', 'A'), String('ifnot', name='ifnot_field5'), name='ifnot4'), Group(name='test_group_5', values=['A', 'B', 'C']) ] uut = self.get_default_container(fields) uut_copy = uut.copy() uut_mutations = self.get_all_mutations(uut, reset=False) copy_mutations = self.get_all_mutations(uut_copy, reset=False) self.assertEqual(uut_mutations, copy_mutations)
def testGetRenderedFieldsCorrect(self): fields = [ String('test_string', name='field1'), If(Equal('test_group_5', 'A'), String('if', name='if_field3'), name='if2'), IfNot(Equal('test_group_5', 'A'), String('ifnot', name='ifnot_field5'), name='ifnot4'), Group(name='test_group_5', values=['A', 'B', 'C']) ] container = self.get_default_container(fields) if len(container.render()): self.assertEqual(len(container.get_rendered_fields()), 1) while container.mutate(): if len(container.render()): self.assertEqual(len(container.get_rendered_fields()), 1) else: self.assertEqual(len(container.get_rendered_fields()), 0)
def testStringGroupMutatingMutatedField(self): mutated = String('test', max_size=10) field = Group(values=['a', 'b', 'c']) self._test_mutating_mutated(mutated, field)
def testStringGroup(self): mutated = String('test', max_size=10) field = Group(values=['a', 'b', 'c']) self._test_basic(mutated, field)
def testGroupStringMutatingMutatedField(self): mutated = Group(values=['1', '2', '3']) field = String('best') self._test_mutating_mutated(mutated, field)
def testGroupString(self): mutated = Group(values=['1', '2', '3']) field = String('best', max_size=10) self._test_basic(mutated, field)
def testGroupGroupMutatingMutatedField(self): mutated = Group(values=['1', '2', '3']) field = Group(values=['a', 'b', 'c']) self._test_mutating_mutated(mutated, field)
def testGroupGroup(self): mutated = Group(values=['1', '2', '3']) field = Group(values=['a', 'b', 'c']) self._test_basic(mutated, field)