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

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

    events['types'].append({ 'name': 'Event' })
    # 'Event' has no 'functions'.
    self.assertRaises(AssertionError, _GetAddRulesDefinitionFromEvents, events)

    events['types'][0]['functions'] = []
    # No 'functions' named 'addRules'.
    self.assertRaises(AssertionError, _GetAddRulesDefinitionFromEvents, events)

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

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