def test_not_send_anything_if_user_does_not_have_proposals(self): user = User.objects.create_user(username="******", email="*****@*****.**") initial_amount_of_mails = len(mail.outbox) r = PeriodicReporter(user) r.send_mail() amount_of_mails = len(mail.outbox) self.assertEquals(amount_of_mails, initial_amount_of_mails)
def report_sender_task(): users_with_proposals = User.objects.exclude(proposals__isnull=True) if not config.PERIODIC_REPORTS_ENABLED: users_with_proposals = users_with_proposals.filter(is_staff=True) for u in users_with_proposals: r = PeriodicReporter(u) r.send_mail()
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_not_send_anything_if_user_does_not_have_proposals(self): user = User.objects.create_user(username="******", email="*****@*****.**") initial_amount_of_mails = len(mail.outbox) r = PeriodicReporter(user) r.send_mail() amount_of_mails = len(mail.outbox) self.assertEquals(amount_of_mails, initial_amount_of_mails)
def test_send_mail(self): initial_amount_of_mails = len(mail.outbox) r = PeriodicReporter(self.fiera) r.send_mail() amount_of_mails = len(mail.outbox) self.assertEquals(amount_of_mails, initial_amount_of_mails + 1) the_mail = mail.outbox[amount_of_mails - 1] self.assertEquals(len(the_mail.to), 1) self.assertIn(self.fiera.email, the_mail.to)
def test_send_mail(self): initial_amount_of_mails = len(mail.outbox) r = PeriodicReporter(self.fiera) r.send_mail() amount_of_mails = len(mail.outbox) self.assertEquals(amount_of_mails, initial_amount_of_mails + 1) the_mail = mail.outbox[amount_of_mails - 1] self.assertEquals(len(the_mail.to), 1) self.assertIn(self.fiera.email, the_mail.to)
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 report_sender_task(): users_with_proposals = User.objects.exclude(proposals__isnull=True) if not config.PERIODIC_REPORTS_ENABLED: users_with_proposals = users_with_proposals.filter(is_staff=True) for u in users_with_proposals: r = PeriodicReporter(u) r.send_mail() ## send_mails_to_staff({'number': users_with_proposals}, 'notice_to_staff_of_periodic_reports')
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 report_sender_task(): users_with_proposals = User.objects.exclude(proposals__isnull=True) if not config.PERIODIC_REPORTS_ENABLED: users_with_proposals = users_with_proposals.filter(is_staff=True) for u in users_with_proposals: r = PeriodicReporter(u) r.send_mail() ## send_mails_to_staff({'number': users_with_proposals}, 'notice_to_staff_of_periodic_reports')
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_sending_mail_with_recomendation_comes_with_new_proposals(self): initial_amount_of_mails = len(mail.outbox) r = PeriodicReporter(self.fiera) r.send_mail() amount_of_mails = len(mail.outbox) self.assertEquals(amount_of_mails, initial_amount_of_mails + 1)
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_sending_mail_with_recomendation_comes_with_new_proposals(self): initial_amount_of_mails = len(mail.outbox) r = PeriodicReporter(self.fiera) r.send_mail() amount_of_mails = len(mail.outbox) self.assertEquals(amount_of_mails, initial_amount_of_mails + 1)