def test_multi_oneele(self): result = policy._parse_list_rule([['rule1'], ['rule2']]) self.assertTrue(isinstance(result, policy.OrCheck)) self.assertEqual(len(result.rules), 2) for i, value in enumerate(['rule1', 'rule2']): self.assertTrue(isinstance(result.rules[i], FakeCheck)) self.assertEqual(result.rules[i].result, value) self.assertEqual(str(result), '(rule1 or rule2)')
def test_multi_multi(self): result = policy._parse_list_rule([['rule1', 'rule2'], ['rule3', 'rule4']]) self.assertTrue(isinstance(result, policy.OrCheck)) self.assertEqual(len(result.rules), 2) for i, values in enumerate([['rule1', 'rule2'], ['rule3', 'rule4']]): self.assertTrue(isinstance(result.rules[i], policy.AndCheck)) self.assertEqual(len(result.rules[i].rules), 2) for j, value in enumerate(values): self.assertTrue(isinstance(result.rules[i].rules[j], FakeCheck)) self.assertEqual(result.rules[i].rules[j].result, value) self.assertEqual(str(result), '((rule1 and rule2) or (rule3 and rule4))')
def test_oneele_oneele(self): result = policy._parse_list_rule([['rule']]) self.assertTrue(isinstance(result, FakeCheck)) self.assertEqual(result.result, 'rule') self.assertEqual(str(result), 'rule')
def test_oneele_zeroele(self): result = policy._parse_list_rule([[]]) self.assertTrue(isinstance(result, policy.FalseCheck)) self.assertEqual(str(result), '!')
def test_empty(self): result = policy._parse_list_rule([]) self.assertTrue(isinstance(result, policy.TrueCheck)) self.assertEqual(str(result), '@')