def test_send_notification_on_change_only_with_no_changes(self): self.project.notification_strategy = Project.NOTIFY_ON_CHANGE self.project.save() self.project.subscriptions.create(email='*****@*****.**') ProjectStatus.create_or_update(self.build2) send_notification(self.project) self.assertEqual(0, len(mail.outbox))
def test_send_notification_only_once(self, diff): self.project.subscriptions.create(email='*****@*****.**') diff.return_value = fake_diff() ProjectStatus.create_or_update(self.build2) send_notification(self.project) send_notification(self.project) self.assertEqual(1, len(mail.outbox))
def test_send_notification_for_all_builds(self, diff): t = timezone.now() - relativedelta(hours=2.5) self.project.builds.create(version='3', datetime=t) self.project.subscriptions.create(email='*****@*****.**') diff.return_value = fake_diff() send_notification(self.project) self.assertEqual(2, len(mail.outbox))
def test_send_notification_on_change_only(self, diff): diff.return_value = fake_diff() self.project.notification_strategy = Project.NOTIFY_ON_CHANGE self.project.save() self.project.subscriptions.create(email='*****@*****.**') send_notification(self.project) self.assertEqual(1, len(mail.outbox))
def test_send_plain_text_only(self): self.project.subscriptions.create(email='*****@*****.**') self.project.html_mail = False self.project.save() ProjectStatus.create_or_update(self.build2) send_notification(self.project) msg = mail.outbox[0] self.assertEqual(0, len(msg.alternatives))
def test_send_all_pending_notifications(self): self.project.subscriptions.create(email='*****@*****.**') ProjectStatus.create_or_update(self.build2) t = timezone.now() - relativedelta(hours=2.5) build3 = self.project.builds.create(version='3', datetime=t) ProjectStatus.create_or_update(build3) send_notification(self.project) self.assertEqual(2, len(mail.outbox))
def test_send_notification_for_all_builds(self, diff): self.project.subscriptions.create(email='*****@*****.**') diff.return_value = fake_diff() ProjectStatus.create_or_update(self.build2) send_notification(self.project) self.assertEqual(1, len(mail.outbox)) t = timezone.now() - relativedelta(hours=2.5) build = self.project.builds.create(version='3', datetime=t) ProjectStatus.create_or_update(build) # project.status is cached, get a new instance project = Project.objects.get(pk=self.project.id) send_notification(project) self.assertEqual(2, len(mail.outbox))
def notify_project(project_id): project = Project.objects.get(pk=project_id) send_notification(project)
def test_dont_send_if_notifying_on_change(self): self.project.notification_strategy = Project.NOTIFY_ON_CHANGE self.project.save() ProjectStatus.create_or_update(self.build) send_notification(self.project) self.assertEqual(0, len(mail.outbox))
def test_send_if_notifying_all_builds(self): ProjectStatus.create_or_update(self.build) send_notification(self.project) self.assertEqual(1, len(mail.outbox))
def test_send_a_single_notification_email(self): self.project.subscriptions.create(email='*****@*****.**') self.project.subscriptions.create(email='*****@*****.**') ProjectStatus.create_or_update(self.build2) send_notification(self.project) self.assertEqual(1, len(mail.outbox))
def test_no_recipients_no_email(self, diff): diff.return_value = fake_diff() ProjectStatus.create_or_update(self.build2) send_notification(self.project) self.assertEqual(0, len(mail.outbox))
def test_send_notification(self, diff): self.project.subscriptions.create(email='*****@*****.**') diff.return_value = fake_diff() send_notification(self.project) self.assertEqual(1, len(mail.outbox))
def test_send_if_notifying_all_builds(self): send_notification(self.project) self.assertEqual(1, len(mail.outbox))
def test_no_recipients_no_email(self, diff): diff.return_value = fake_diff() send_notification(self.project) self.assertEqual(0, len(mail.outbox))