def test_to_councillor(self): rule = EmailRule( is_cc=False, rule=EmailRule.TO_COUNCILLOR, city = self.test_city ) self.assertEqual("All reports", rule.label()) self.assertEqual(self.test_ward.councillor.email,rule.value(self.test_ward)) self.assertEqual("the councillor's email address",rule.value()) describer = EmailRuleDescriber("All reports") describer.add_rule(rule,self.test_ward) expect = "All reports will be sent to:%s"%(self.test_ward.councillor.email) self.assertEqual( expect , unicode(describer))
def test_not_category_match(self): parks_category = ReportCategory.objects.get(name_en='Lights Malfunctioning in Park') parks_category_class = ReportCategoryClass.objects.get(name_en='Parks') rule = EmailRule(rule=EmailRule.NOT_MATCHING_CATEGORY_CLASS, city =self.test_city, category_class = parks_category_class, email='*****@*****.**' ) self.assertEqual("non-'Parks' reports", rule.label()) self.assertEqual('*****@*****.**',rule.value(self.test_ward)) self.assertEqual('*****@*****.**',rule.value(None)) describer = EmailRuleDescriber("non-'Parks' reports") describer.add_rule(rule,self.test_ward) expect = "non-'Parks' reports will be sent to:[email protected]" self.assertEqual( expect , unicode(describer))