def testGetEventByNameFromEvents(self):
        events = {}
        # Missing 'types' completely.
        self.assertRaises(AssertionError, _GetEventByNameFromEvents, events)

        events["types"] = []
        # No type 'Event' defined.
        self.assertRaises(AssertionError, _GetEventByNameFromEvents, events)

        events["types"].append({"name": "Event", "functions": []})
        add_rules = {"name": "addRules"}
        events["types"][0]["functions"].append(add_rules)
        self.assertEqual(add_rules, _GetEventByNameFromEvents(events)["addRules"])

        events["types"][0]["functions"].append(add_rules)
        # Duplicates are an error.
        self.assertRaises(AssertionError, _GetEventByNameFromEvents, events)
Beispiel #2
0
    def testGetEventByNameFromEvents(self):
        events = {}
        # Missing 'types' completely.
        self.assertRaises(AssertionError, _GetEventByNameFromEvents, events)

        events['types'] = []
        # No type 'Event' defined.
        self.assertRaises(AssertionError, _GetEventByNameFromEvents, events)

        events['types'].append({'name': 'Event', 'functions': []})
        add_rules = {"name": "addRules"}
        events['types'][0]['functions'].append(add_rules)
        self.assertEqual(add_rules,
                         _GetEventByNameFromEvents(events)['addRules'])

        events['types'][0]['functions'].append(add_rules)
        # Duplicates are an error.
        self.assertRaises(AssertionError, _GetEventByNameFromEvents, events)
Beispiel #3
0
 def _FakeLoadAddRulesSchema(self):
     events = self._LoadJSON('add_rules_def_test.json')
     return _GetEventByNameFromEvents(events)
 def _FakeLoadAddRulesSchema(self):
   events = self._LoadJSON('add_rules_def_test.json')
   return Future(value=_GetEventByNameFromEvents(events))