def explain_service(rule): response = {"rule":rule} try: response["explanation"] = explain(rule) response["translations_required"] = len(explain(rule)) except RuleError: response["explanation"] = None response["translations_required"] = 0 response["error"] = "Invalid rule specified" response = make_response(json.dumps(response)) response.mimetype = 'application/json' return response
def test_6forms(self): # expect rule 12 to have 6 forms self.assertEqual(len(explain(12)), 6)
def test_5forms(self): # expect rule 11 to have 5 forms self.assertEqual(len(explain(11)), 5)
def test_4forms_13(self): self.assertEqual(len(explain(13)), 4)
def test_4forms_4(self): self.assertEqual(len(explain(4)), 4)
def test_3forms_14(self): self.assertEqual(len(explain(14)), 3)
def test_3forms_9(self): self.assertEqual(len(explain(9)), 3)
def test_2forms_15(self): self.assertEqual(len(explain(15)), 2)
def test_2forms_2(self): self.assertEqual(len(explain(2)), 2)
def test_1form(self): # expect rule 0 to have 1 form self.assertEqual(len(explain(0)), 1)