From 99bfc340f9c97d8266722dde045517f62180a39a Mon Sep 17 00:00:00 2001 From: Bruno Tikami Date: Wed, 17 Feb 2016 21:43:33 -0200 Subject: [PATCH] ADDED: --- helpdesk/tests/test_ticket_submission.py | 29 ++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/helpdesk/tests/test_ticket_submission.py b/helpdesk/tests/test_ticket_submission.py index cc4c9ad5..899b391f 100644 --- a/helpdesk/tests/test_ticket_submission.py +++ b/helpdesk/tests/test_ticket_submission.py @@ -76,6 +76,35 @@ class TicketBasicsTestCase(TestCase): # and the new and update queues (+2) self.assertEqual(email_count + 1 + 2, len(mail.outbox)) + def test_create_ticket_from_email_without_message_id(self): + + """ + Ensure that a instance is created whenever an email is sent to a public queue. + Also, make sure that the RFC 2822 field "message-id" is stored on the + field. + """ + + msg = email.message.Message() + submitter_email = 'foo@bar.py' + + msg.__setitem__('Subject', self.ticket_data['title']) + msg.__setitem__('From', submitter_email) + msg.__setitem__('To', self.queue_public.email_address) + msg.__setitem__('Content-Type', 'text/plain;') + msg.set_payload(self.ticket_data['description']) + + email_count = len(mail.outbox) + + object_from_message(str(msg), self.queue_public, quiet=True) + + ticket = Ticket.objects.get(title=self.ticket_data['title'], queue=self.queue_public, submitter_email=submitter_email) + + self.assertEqual(ticket.ticket_for_url, "q1-%s" % ticket.id) + + # As we have created an Ticket from an email, we notify the sender (+1) + # and the new and update queues (+2) + self.assertEqual(email_count + 1 + 2, len(mail.outbox)) + def test_create_ticket_from_email_with_carbon_copy(self):