def test_get_context_for_only_one_day(self): r = PeriodicReporter(self.fiera, days=1) context = r.get_mail_context() self.assertEquals(context['proposals'][0]['analytics']['commitments'], 0) self.assertEquals(context['proposals'][0]['analytics']['visits'], 0) self.assertEquals(context['proposals'][0]['analytics']['likers'], 0)
def test_instantiate_and_get_attributes(self): r = PeriodicReporter(self.fiera) self.assertEquals(r.mail_template, 'periodic_report') proposals = r.get_proposals() self.assertIn(self.popular_proposal, proposals) context = r.get_mail_context() self.assertEquals(context['user'], self.fiera) self.assertEquals(context['proposals'][0]['proposal'], self.popular_proposal) self.assertEquals(context['proposals'][0]['analytics'], self.popular_proposal.get_analytics())
def test_instantiate_and_get_attributes(self): r = PeriodicReporter(self.fiera) self.assertEquals(r.mail_template, 'periodic_report') proposals = r.get_proposals() self.assertIn(self.popular_proposal, proposals) context = r.get_mail_context() self.assertEquals(context['user'], self.fiera) self.assertEquals(context['proposals'][0]['proposal'], self.popular_proposal) self.assertEquals(context['proposals'][0]['analytics'], self.popular_proposal.get_analytics())
def test_recomendation_comes_with_new_proposals(self): should_not_be_1 = PopularProposal.objects.create(proposer=self.feli, area=self.arica, data=self.data, title=u'old proposal', clasification=u'education', ) should_not_be_1.created = TWO_DAYS_AGO should_not_be_1.save() r = PeriodicReporter(self.fiera, days=1) context = r.get_mail_context() new_proposals = context['new_proposals'] self.assertIn(self.should_be_1, new_proposals) self.assertNotIn(self.should_not_be_in_recomendation, new_proposals) self.assertNotIn(self.should_not_be_in_recomendation2, new_proposals) self.assertNotIn(should_not_be_1, new_proposals)
def test_recomendation_comes_with_new_proposals(self): should_not_be_1 = PopularProposal.objects.create( proposer=self.feli, area=self.arica, data=self.data, title=u'old proposal', clasification=u'education', ) should_not_be_1.created = TWO_DAYS_AGO should_not_be_1.save() r = PeriodicReporter(self.fiera, days=1) context = r.get_mail_context() new_proposals = context['new_proposals'] self.assertIn(self.should_be_1, new_proposals) self.assertNotIn(self.should_not_be_in_recomendation, new_proposals) self.assertNotIn(self.should_not_be_in_recomendation2, new_proposals) self.assertNotIn(should_not_be_1, new_proposals)
def test_get_context_for_only_one_day(self): r = PeriodicReporter(self.fiera, days=1) context = r.get_mail_context() self.assertEquals(context['proposals'][0]['analytics']['commitments'], 0) self.assertEquals(context['proposals'][0]['analytics']['visits'], 0) self.assertEquals(context['proposals'][0]['analytics']['likers'], 0)