Example #1
0
 def test_get_children_with_filters_no_ancestry(self):
     filters = [
         Filter(action='mod1_filter2', args={'arg1': '5.4'}),
         Filter(action='Top Filter')
     ]
     flag = Flag(action='Top Flag', filters=filters)
     self.assertDictEqual(flag.get_children([]),
                          flag.as_json(with_children=False))
Example #2
0
    def test_get_children(self):
        names = ['action1', '', 'action2']
        flag1 = Flag()
        for name in names:
            self.assertIsNone(flag1.get_children([name]))
            self.assertDictEqual(flag1.get_children([]),
                                 flag1.as_json(with_children=False))

        filters = [
            Filter(action='action1'),
            Filter(),
            Filter(action='action2')
        ]
        flag2 = Flag(filters=filters)
        for i, name in enumerate(names):
            self.assertDictEqual(flag2.get_children([name]),
                                 filters[i].as_json())
            self.assertDictEqual(flag2.get_children([]),
                                 flag2.as_json(with_children=False))
Example #3
0
 def test_as_json_with_args_with_children(self):
     flag = Flag(action='mod1_flag2', args={'arg1': '11113'})
     expected = {
         'action': 'mod1_flag2',
         'args': {
             'arg1': {
                 'format': 'integer',
                 'key': 'arg1',
                 'value': 11113
             }
         },
         'filters': []
     }
     self.assertDictEqual(flag.as_json(), expected)
Example #4
0
 def test_as_json_with_args_and_filters_without_children(self):
     filters = [
         Filter(action='mod1_filter2', args={'arg1': '5.4'}),
         Filter(action='Top Filter')
     ]
     flag = Flag(action='mod1_flag2',
                 args={'arg1': '11113'},
                 filters=filters)
     filters_json = [filter_element.name for filter_element in flag.filters]
     expected = {
         'action': 'mod1_flag2',
         'args': {
             'arg1': {
                 'format': 'integer',
                 'key': 'arg1',
                 'value': 11113
             }
         },
         'filters': filters_json
     }
     self.assertDictEqual(flag.as_json(with_children=False), expected)
Example #5
0
 def test_as_json_action_only_without_children(self):
     flag = Flag(action='Top Flag')
     expected = {'action': 'Top Flag', 'args': {}, 'filters': []}
     self.assertDictEqual(flag.as_json(with_children=False), expected)
Example #6
0
 def test_get_children_no_filters_no_ancestry(self):
     flag = Flag(action='Top Flag')
     self.assertDictEqual(flag.get_children([]),
                          flag.as_json(with_children=False))
Example #7
0
 def __assert_xml_is_convertible(self, flag):
     original_json = flag.as_json()
     original_xml = flag.to_xml()
     new_flag = Flag(xml=original_xml)
     self.assertDictEqual(new_flag.as_json(), original_json)