コード例 #1
0
 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(), [])
コード例 #2
0
 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)
コード例 #3
0
 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)
コード例 #4
0
 def testStringGroupMutatingMutatedField(self):
     mutated = String('test', max_size=10)
     field = Group(values=['a', 'b', 'c'])
     self._test_mutating_mutated(mutated, field)
コード例 #5
0
 def testStringGroup(self):
     mutated = String('test', max_size=10)
     field = Group(values=['a', 'b', 'c'])
     self._test_basic(mutated, field)
コード例 #6
0
 def testGroupStringMutatingMutatedField(self):
     mutated = Group(values=['1', '2', '3'])
     field = String('best')
     self._test_mutating_mutated(mutated, field)
コード例 #7
0
 def testGroupString(self):
     mutated = Group(values=['1', '2', '3'])
     field = String('best', max_size=10)
     self._test_basic(mutated, field)
コード例 #8
0
 def testGroupGroupMutatingMutatedField(self):
     mutated = Group(values=['1', '2', '3'])
     field = Group(values=['a', 'b', 'c'])
     self._test_mutating_mutated(mutated, field)
コード例 #9
0
 def testGroupGroup(self):
     mutated = Group(values=['1', '2', '3'])
     field = Group(values=['a', 'b', 'c'])
     self._test_basic(mutated, field)