def test_handle_message(self): handle_message(self.simplemsg) self.assertEquals(1, self.sla.issue_set.all().count()) notification = NotificationsBin.receive() self.assertEquals([FROM], notification['to'])
def test_handle_message_with_extended_from(self): handle_message(self.simplemsg) self.assertEquals(1, self.sla.issue_set.all().count()) notification = NotificationsBin.receive() self.assertEquals([FROM], notification["to"]) self.assertEquals(TO, notification["from"])
def test_notify(self): status = Status.objects.create(name=settings.ISSUE_STATUS_CLOSED, issue=self.issue, comment="Closed!") status.save() try: notification = NotificationsBin.receive() except: self.fail("We should have mail!")
def test_notify(self): settings.NOTIFICATION_BLACKLIST = [ "*****@*****.**", "*****@*****.**" ] context = { "from": "*****@*****.**", "to": "*****@*****.**", "issue": TestIssue() } notify("issue_created", context, "*****@*****.**", "*****@*****.**") try: notification = NotificationsBin.receive() self.fail("We should not have mail!") except: pass notify("issue_created", context, "*****@*****.**", "[email protected], [email protected]") try: notification = NotificationsBin.receive() self.fail("We should not have mail!") except: pass notify("issue_created", context, "*****@*****.**", "[email protected], [email protected]") try: notification = NotificationsBin.receive() except: self.fail("We should have mail!") # reset... settings.NOTIFICATION_BLACKLIST = []
def test_notify(self): status = Status.objects.create( name=settings.ISSUE_STATUS_CLOSED, issue=self.issue, comment="Closed!") status.save() try: notification = NotificationsBin.receive() except: self.fail("We should have mail!")
def test_handle_message_with_attachments(self): handle_message(self.multipartmsg) self.assertEquals(1, self.sla.issue_set.all().count()) issue = self.sla.issue_set.all()[0] self.assertEquals(1, issue.attachment_set.all().count()) notification = NotificationsBin.receive() self.assertEquals([FROM], notification['to']) self.assertEquals(TO, notification['from'])
def test_notify(self): settings.NOTIFICATION_BLACKLIST = ["*****@*****.**", "*****@*****.**"] context = {"from": "*****@*****.**", "to": "*****@*****.**", "issue": TestIssue()} notify("issue_created", context, "*****@*****.**", "*****@*****.**") try: notification = NotificationsBin.receive() self.fail("We should not have mail!") except: pass notify("issue_created", context, "*****@*****.**", "[email protected], [email protected]") try: notification = NotificationsBin.receive() self.fail("We should not have mail!") except: pass notify("issue_created", context, "*****@*****.**", "[email protected], [email protected]") try: notification = NotificationsBin.receive() except: self.fail("We should have mail!") # reset... settings.NOTIFICATION_BLACKLIST = []
def test_notification(self): contact = Contact.objects.create(email="*****@*****.**") contact.save() issue = Issue.objects.create( title="broken stuff", contact=contact, text="Well, it's really broken") issue.save() notification = NotificationsBin.receive() issue_url = reverse( 'view_issue', args=[], kwargs={'pk': issue.pk}) self.assertTrue(issue_url in notification["body"])
def test_handle_message_sla_with_default_service(self): service = Service.objects.create(sla=self.sla, priority="laag") self.sla.default_service = service self.sla.save() handle_message(self.simplemsg) self.assertEquals(1, self.sla.issue_set.all().count()) self.assertEquals(service, self.sla.issue_set.all()[0].service) notification = NotificationsBin.receive() self.assertEquals([FROM], notification['to']) self.assertEquals(TO, notification['from'])
def test_handle_bouncing_issue(self): msg = MIMEText("It's broken", 'plain') msg['From'] = "*****@*****.**" msg['To'] = "*****@*****.**" msg['Subject'] = "help!" import mrwolfe.utils as utils utils.settings.ALLOW_NON_CONTACTS = False handle_message(msg) self.assertEquals(0, Issue.objects.all().count()) notification = NotificationsBin.receive() self.assertEquals("Invalid contact for support", notification['subject'])
def test_handle_message_with_existing_issue(self): handle_message(self.simplemsg) self.assertEquals(1, self.sla.issue_set.all().count()) issue = self.sla.issue_set.all()[0] self.simplemsg.replace_header('subject', "Re: %s" % issue.issue_id) handle_message(self.simplemsg) self.assertEquals(1, self.sla.issue_set.all().count()) self.assertEquals(1, issue.comments.all().count()) notification = NotificationsBin.receive() self.assertEquals([FROM], notification['to']) self.assertEquals(TO, notification['from'])
def test_notification(self): contact = Contact.objects.create(email="*****@*****.**") contact.save() user = User.objects.create(username="******", is_superuser=False) Operator.objects.create(user=user, email="*****@*****.**") issue = Issue.objects.create(title="broken stuff", contact=contact, text="Well, it's really broken") issue.save() notification = NotificationsBin.receive() issue_url = reverse('view_issue', args=[], kwargs={'pk': issue.pk }) self.assertTrue(issue_url in notification["body"])