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 get_not_applies_first_condition(self):
     return Equal(ConditionTest.condition_field_name,
                  ConditionTest.condition_field_value)