def test_basic_rules(self): rules = [ { 'sub.key': 'value', 'out': 1 }, { 'name': 'test', 'out': 2 }, { 'name': { 'length': 4 }, 'out': 3 }, { 'group': 'lol', 'out': 4 }, { 'group': 'wtf', 'out': 5 }, { 'name': { 'length': 5 }, 'out': 6 }, ] matches = list(rule_matcher(TestObject(), rules)) self.assertEqual(matches, [1, 2, 3, 4])
def test_catch_all(self): rules = [{'out': 1}] matches = list(rule_matcher(TestObject(), rules)) self.assertEqual(matches, [1])
def get_command_override(self, command): return rule_matcher(command, self.overrides or [])