Beispiel #1
0
 def test(self):
     email = '*****@*****.**'
     rule = EmailRule( rule=EmailRule.NOT_MATCHING_CATEGORY_CLASS, city = self.test_city, category_class = self.test_categoryclass, email=email )
     rule.save()
     self.failUnlessEqual( self.test_ward.get_emails(self.test_report), ([],[]) )
     report2 = Report(ward=self.test_ward,category=self.not_test_category)
     self.failUnlessEqual( self.test_ward.get_emails(report2), ([email],[]) )
 def test(self):
     email = '*****@*****.**'
     rule = EmailRule( rule=EmailRule.NOT_MATCHING_CATEGORY_CLASS, city = self.test_city, category_class = self.test_categoryclass, email=email )
     rule.save()
     self.failUnlessEqual( self.test_ward.get_emails(self.test_report), ([],[]) )
     report2 = Report(ward=self.test_ward,category=self.not_test_category)
     self.failUnlessEqual( self.test_ward.get_emails(report2), ([email],[]) )
Beispiel #3
0
 def test(self):
     email = '*****@*****.**'
     rule = EmailRule( rule=EmailRule.TO_WARD, city = self.test_city )
     rule.save()
     self.test_ward.councillor = None
     self.test_ward.email = email
     self.test_ward.save()
     self.failUnlessEqual( self.test_ward.get_emails(self.test_report), ([email],[]) )
Beispiel #4
0
 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))
Beispiel #5
0
 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))
Beispiel #6
0
    def test(self):

        # simulate Charlottetown's somewhat complicated cases:
        # 
        # For all categories except Parks, send email to  [email protected]  and  [email protected]
        # with a Cc: to [email protected]  and  the ward councillor.
        #
        # For the category of Parks, send email to:  [email protected]
        # with a Cc: to  [email protected]  and  the ward councillor   
        #
        parks_category = ReportCategory.objects.get(name_en='Lights Malfunctioning in Park')
        not_parks_category = ReportCategory.objects.get(name_en='Damaged Curb')
        parks_category_class = ReportCategoryClass.objects.get(name_en='Parks')
        
        # always CC the councillor
        EmailRule( is_cc=True, rule=EmailRule.TO_COUNCILLOR, city = self.test_city ).save()
        
        # parks rules
        EmailRule(rule=EmailRule.MATCHING_CATEGORY_CLASS, city =self.test_city, category_class = parks_category_class, email='*****@*****.**' ).save()
        EmailRule(rule=EmailRule.MATCHING_CATEGORY_CLASS, city =self.test_city, category_class = parks_category_class, email='*****@*****.**', is_cc=True ).save()

        # not parks rules
        EmailRule( rule=EmailRule.NOT_MATCHING_CATEGORY_CLASS, city = self.test_city, category_class = parks_category_class, email='*****@*****.**' ).save()
        EmailRule( rule=EmailRule.NOT_MATCHING_CATEGORY_CLASS, city = self.test_city, category_class = parks_category_class, email='*****@*****.**' ).save()
        EmailRule( rule=EmailRule.NOT_MATCHING_CATEGORY_CLASS, city = self.test_city, category_class = parks_category_class, email='*****@*****.**', is_cc=True ).save()
        
        parks_report = Report(ward=self.test_ward,category = parks_category )
        self.failUnlessEqual( self.test_ward.get_emails(parks_report), ([ u'*****@*****.**' ],[u"*****@*****.**", u'*****@*****.**'] ))
        
        not_parks_report = Report(ward=self.test_ward,category = not_parks_category )
        self.failUnlessEqual( self.test_ward.get_emails(not_parks_report), ([ u'*****@*****.**',u'*****@*****.**' ], [u"*****@*****.**",u'*****@*****.**'] ))
Beispiel #7
0
    def test_pei(self):
                # simulate Charlottetown's somewhat complicated cases:
        # 
        # For all categories except Parks, send email to  [email protected]  and  [email protected]
        # with a Cc: to [email protected]  and  the ward councillor.
        #
        # For the category of Parks, send email to:  [email protected]
        # with a Cc: to  [email protected]  and  the ward councillor   
        #
        parks_category = ReportCategory.objects.get(name_en='Lights Malfunctioning in Park')
        not_parks_category = ReportCategory.objects.get(name_en='Damaged Curb')
        parks_category_class = ReportCategoryClass.objects.get(name_en='Parks')
        
        # always CC the councillor
        EmailRule( is_cc=True, rule=EmailRule.TO_COUNCILLOR, city = self.test_city ).save()
        
        # parks rules
        EmailRule(rule=EmailRule.MATCHING_CATEGORY_CLASS, city =self.test_city, category_class = parks_category_class, email='*****@*****.**' ).save()
        EmailRule(rule=EmailRule.MATCHING_CATEGORY_CLASS, city =self.test_city, category_class = parks_category_class, email='*****@*****.**', is_cc=True ).save()

        # not parks rules
        EmailRule( rule=EmailRule.NOT_MATCHING_CATEGORY_CLASS, city = self.test_city, category_class = parks_category_class, email='*****@*****.**' ).save()
        EmailRule( rule=EmailRule.NOT_MATCHING_CATEGORY_CLASS, city = self.test_city, category_class = parks_category_class, email='*****@*****.**' ).save()
        EmailRule( rule=EmailRule.NOT_MATCHING_CATEGORY_CLASS, city = self.test_city, category_class = parks_category_class, email='*****@*****.**', is_cc=True ).save()
        
        descs = self.test_ward.get_rule_descriptions()
        self.assertEquals(3,len(descs))
        self.assertEquals("All reports will be cc'd to:[email protected]",unicode(descs[0]))
        self.assertEquals("'Parks' reports will be sent to:[email protected] and cc'd to:[email protected]",unicode(descs[1]))
        self.assertEquals("non-'Parks' reports will be sent to:[email protected],[email protected] and cc'd to:[email protected]",unicode(descs[2]))
        
        city_descs = self.test_city.get_rule_descriptions()
        self.assertEquals(3,len(city_descs))
        self.assertEquals("All reports will be cc'd to:the councillor's email address",unicode(city_descs[0]))
        self.assertEquals("'Parks' reports will be sent to:[email protected] and cc'd to:[email protected]",unicode(city_descs[1]))
        self.assertEquals("non-'Parks' reports will be sent to:[email protected],[email protected] and cc'd to:[email protected]",unicode(city_descs[2]))
 def test(self):
     rule = EmailRule( rule=EmailRule.TO_COUNCILLOR, city = self.test_city )
     rule.save()
     self.failUnlessEqual( self.test_ward.get_emails(self.test_report), ([self.test_report.ward.councillor.email],[]) )
Beispiel #9
0
 def test(self):
     rule = EmailRule( rule=EmailRule.TO_COUNCILLOR, city = self.test_city )
     rule.save()
     self.failUnlessEqual( self.test_ward.get_emails(self.test_report), ([self.test_report.ward.councillor.email],[]) )