def test_create(self): n = Rule.objects.count() rule = Rule.create(self.input, self.rule_set) self.assertEqual(Rule.objects.count(), n + 1) if self.input["type"].lower() != "string": self.assertEqual(rule.category, self.input["nodeset"].split("/")[-1]) else: self.assertEqual(rule.category, "All Responses")
def test_as_json(self): rule = Rule.create(self.input, self.rule_set) _json = rule.as_json(False) self.assertEqual(_json["test"], rule.test.as_json(False)) self.assertEqual(_json["category"], {"eng": rule.category}) self.assertEqual(_json["uuid"], unicode(rule.uuid))