mirror of
https://github.com/django-helpdesk/django-helpdesk.git
synced 2025-02-07 13:59:39 +01:00
PEP-8 fixes for mail threading merge
This commit is contained in:
parent
5f0d22a692
commit
43ed3ac773
@ -318,7 +318,7 @@ def create_object_from_email_message(message, ticket_id, payload, files, logger)
|
|||||||
previous_followup = queryset.first()
|
previous_followup = queryset.first()
|
||||||
ticket = previous_followup.ticket
|
ticket = previous_followup.ticket
|
||||||
except FollowUp.DoesNotExist:
|
except FollowUp.DoesNotExist:
|
||||||
pass #play along. The header may be wrong
|
pass # play along. The header may be wrong
|
||||||
|
|
||||||
if previous_followup is None and ticket_id is not None:
|
if previous_followup is None and ticket_id is not None:
|
||||||
try:
|
try:
|
||||||
@ -331,12 +331,12 @@ def create_object_from_email_message(message, ticket_id, payload, files, logger)
|
|||||||
if ticket is None:
|
if ticket is None:
|
||||||
if not settings.QUEUE_EMAIL_BOX_UPDATE_ONLY:
|
if not settings.QUEUE_EMAIL_BOX_UPDATE_ONLY:
|
||||||
ticket = Ticket.objects.create(
|
ticket = Ticket.objects.create(
|
||||||
title = payload['subject'],
|
title=payload['subject'],
|
||||||
queue = queue,
|
queue=queue,
|
||||||
submitter_email = sender_email,
|
submitter_email=sender_email,
|
||||||
created = now,
|
created=now,
|
||||||
description = payload['body'],
|
description=payload['body'],
|
||||||
priority = payload['priority'],
|
priority=payload['priority'],
|
||||||
)
|
)
|
||||||
ticket.save()
|
ticket.save()
|
||||||
logger.debug("Created new ticket %s-%s" % (ticket.queue.slug, ticket.id))
|
logger.debug("Created new ticket %s-%s" % (ticket.queue.slug, ticket.id))
|
||||||
@ -350,12 +350,12 @@ def create_object_from_email_message(message, ticket_id, payload, files, logger)
|
|||||||
ticket.save()
|
ticket.save()
|
||||||
|
|
||||||
f = FollowUp(
|
f = FollowUp(
|
||||||
ticket = ticket,
|
ticket=ticket,
|
||||||
title = _('E-Mail Received from %(sender_email)s' % {'sender_email': sender_email}),
|
title=_('E-Mail Received from %(sender_email)s' % {'sender_email': sender_email}),
|
||||||
date = now,
|
date=now,
|
||||||
public = True,
|
public=True,
|
||||||
comment = payload['body'],
|
comment=payload['body'],
|
||||||
message_id = message_id,
|
message_id=message_id
|
||||||
)
|
)
|
||||||
|
|
||||||
if ticket.status == Ticket.REOPENED_STATUS:
|
if ticket.status == Ticket.REOPENED_STATUS:
|
||||||
@ -376,13 +376,13 @@ def create_object_from_email_message(message, ticket_id, payload, files, logger)
|
|||||||
new_ticket_ccs = []
|
new_ticket_ccs = []
|
||||||
new_ticket_ccs.append(create_ticket_cc(ticket, to_list + cc_list))
|
new_ticket_ccs.append(create_ticket_cc(ticket, to_list + cc_list))
|
||||||
|
|
||||||
notifications_to_be_sent = [sender_email,]
|
notifications_to_be_sent = [sender_email]
|
||||||
|
|
||||||
if queue.enable_notifications_on_email_events and len(notifications_to_be_sent):
|
if queue.enable_notifications_on_email_events and len(notifications_to_be_sent):
|
||||||
|
|
||||||
ticket_cc_list = TicketCC.objects.filter(ticket=ticket).all().values_list('email', flat=True)
|
ticket_cc_list = TicketCC.objects.filter(ticket=ticket).all().values_list('email', flat=True)
|
||||||
|
|
||||||
for email in ticket_cc_list :
|
for email in ticket_cc_list:
|
||||||
notifications_to_be_sent.append(email)
|
notifications_to_be_sent.append(email)
|
||||||
|
|
||||||
# send mail to appropriate people now depending on what objects
|
# send mail to appropriate people now depending on what objects
|
||||||
@ -399,13 +399,13 @@ def create_object_from_email_message(message, ticket_id, payload, files, logger)
|
|||||||
context.update(comment=f.comment)
|
context.update(comment=f.comment)
|
||||||
ticket.send(
|
ticket.send(
|
||||||
{'submitter': ('newticket_submitter', context),
|
{'submitter': ('newticket_submitter', context),
|
||||||
'assigned_to': ('updated_owner', context),},
|
'assigned_to': ('updated_owner', context)},
|
||||||
fail_silently=True,
|
fail_silently=True,
|
||||||
extra_headers={'In-Reply-To': message_id},
|
extra_headers={'In-Reply-To': message_id},
|
||||||
)
|
)
|
||||||
if queue.enable_notifications_on_email_events:
|
if queue.enable_notifications_on_email_events:
|
||||||
ticket.send(
|
ticket.send(
|
||||||
{'ticket_cc': ('updated_cc', context),},
|
{'ticket_cc': ('updated_cc', context)},
|
||||||
fail_silently=True,
|
fail_silently=True,
|
||||||
extra_headers={'In-Reply-To': message_id},
|
extra_headers={'In-Reply-To': message_id},
|
||||||
)
|
)
|
||||||
@ -532,4 +532,3 @@ def object_from_message(message, queue, logger):
|
|||||||
}
|
}
|
||||||
|
|
||||||
return create_object_from_email_message(message, ticket, payload, files, logger=logger)
|
return create_object_from_email_message(message, ticket, payload, files, logger=logger)
|
||||||
|
|
||||||
|
@ -139,11 +139,13 @@ class TicketBasicsTestCase(TestCase):
|
|||||||
# Ensure only two e-mails were sent - submitter & updated.
|
# Ensure only two e-mails were sent - submitter & updated.
|
||||||
self.assertEqual(email_count + 2, len(mail.outbox))
|
self.assertEqual(email_count + 2, len(mail.outbox))
|
||||||
|
|
||||||
|
|
||||||
class EmailInteractionsTestCase(TestCase):
|
class EmailInteractionsTestCase(TestCase):
|
||||||
fixtures = ['emailtemplate.json']
|
fixtures = ['emailtemplate.json']
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.queue_public = Queue.objects.create(title='Mail Queue 1',
|
self.queue_public = Queue.objects.create(
|
||||||
|
title='Mail Queue 1',
|
||||||
slug='mq1',
|
slug='mq1',
|
||||||
email_address='queue-1@example.com',
|
email_address='queue-1@example.com',
|
||||||
allow_public_submission=True,
|
allow_public_submission=True,
|
||||||
@ -152,7 +154,8 @@ class EmailInteractionsTestCase(TestCase):
|
|||||||
enable_notifications_on_email_events=True,
|
enable_notifications_on_email_events=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
self.queue_public_with_notifications_disabled = Queue.objects.create(title='Mail Queue 2',
|
self.queue_public_with_notifications_disabled = Queue.objects.create(
|
||||||
|
title='Mail Queue 2',
|
||||||
slug='mq2',
|
slug='mq2',
|
||||||
email_address='queue-2@example.com',
|
email_address='queue-2@example.com',
|
||||||
allow_public_submission=True,
|
allow_public_submission=True,
|
||||||
@ -200,7 +203,7 @@ class EmailInteractionsTestCase(TestCase):
|
|||||||
self.assertEqual(email_count + 1 + 2, len(mail.outbox))
|
self.assertEqual(email_count + 1 + 2, len(mail.outbox))
|
||||||
|
|
||||||
# Ensure that the submitter is notified
|
# Ensure that the submitter is notified
|
||||||
self.assertIn(submitter_email,mail.outbox[0].to)
|
self.assertIn(submitter_email, mail.outbox[0].to)
|
||||||
|
|
||||||
def test_create_ticket_from_email_without_message_id(self):
|
def test_create_ticket_from_email_without_message_id(self):
|
||||||
|
|
||||||
@ -232,10 +235,9 @@ class EmailInteractionsTestCase(TestCase):
|
|||||||
self.assertEqual(email_count + 1 + 2, len(mail.outbox))
|
self.assertEqual(email_count + 1 + 2, len(mail.outbox))
|
||||||
|
|
||||||
# Ensure that the submitter is notified
|
# Ensure that the submitter is notified
|
||||||
self.assertIn(submitter_email,mail.outbox[0].to)
|
self.assertIn(submitter_email, mail.outbox[0].to)
|
||||||
|
|
||||||
def test_create_ticket_from_email_with_carbon_copy(self):
|
def test_create_ticket_from_email_with_carbon_copy(self):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Ensure that an instance of <TicketCC> is created for every valid element of the
|
Ensure that an instance of <TicketCC> is created for every valid element of the
|
||||||
"rfc_2822_cc" field when creating a <Ticket> instance.
|
"rfc_2822_cc" field when creating a <Ticket> instance.
|
||||||
@ -270,13 +272,12 @@ class EmailInteractionsTestCase(TestCase):
|
|||||||
self.assertEqual(email_count + 1 + 2 + 2, len(mail.outbox))
|
self.assertEqual(email_count + 1 + 2 + 2, len(mail.outbox))
|
||||||
|
|
||||||
# Ensure that the submitter is notified
|
# Ensure that the submitter is notified
|
||||||
self.assertIn(submitter_email,mail.outbox[0].to)
|
self.assertIn(submitter_email, mail.outbox[0].to)
|
||||||
|
|
||||||
|
|
||||||
for cc_email in cc_list:
|
for cc_email in cc_list:
|
||||||
|
|
||||||
# Ensure that contacts on cc_list will be notified on the same email (index 0)
|
# Ensure that contacts on cc_list will be notified on the same email (index 0)
|
||||||
#self.assertIn(cc_email, mail.outbox[0].to)
|
# self.assertIn(cc_email, mail.outbox[0].to)
|
||||||
|
|
||||||
# Ensure that <TicketCC> exists
|
# Ensure that <TicketCC> exists
|
||||||
ticket_cc = TicketCC.objects.get(ticket=ticket, email=cc_email)
|
ticket_cc = TicketCC.objects.get(ticket=ticket, email=cc_email)
|
||||||
@ -284,7 +285,6 @@ class EmailInteractionsTestCase(TestCase):
|
|||||||
self.assertTrue(ticket_cc.email, cc_email)
|
self.assertTrue(ticket_cc.email, cc_email)
|
||||||
|
|
||||||
def test_create_ticket_from_email_to_multiple_emails(self):
|
def test_create_ticket_from_email_to_multiple_emails(self):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Ensure that an instance of <TicketCC> is created for every valid element of the
|
Ensure that an instance of <TicketCC> is created for every valid element of the
|
||||||
"rfc_2822_cc" field when creating a <Ticket> instance.
|
"rfc_2822_cc" field when creating a <Ticket> instance.
|
||||||
@ -319,7 +319,7 @@ class EmailInteractionsTestCase(TestCase):
|
|||||||
self.assertEqual(email_count + 1 + 2 + 2, len(mail.outbox))
|
self.assertEqual(email_count + 1 + 2 + 2, len(mail.outbox))
|
||||||
|
|
||||||
# Ensure that the submitter is notified
|
# Ensure that the submitter is notified
|
||||||
self.assertIn(submitter_email,mail.outbox[0].to)
|
self.assertIn(submitter_email, mail.outbox[0].to)
|
||||||
|
|
||||||
# Ensure that the queue's email was not subscribed to the event notifications.
|
# Ensure that the queue's email was not subscribed to the event notifications.
|
||||||
self.assertRaises(TicketCC.DoesNotExist, TicketCC.objects.get, ticket=ticket, email=to_list[0])
|
self.assertRaises(TicketCC.DoesNotExist, TicketCC.objects.get, ticket=ticket, email=to_list[0])
|
||||||
@ -327,7 +327,7 @@ class EmailInteractionsTestCase(TestCase):
|
|||||||
for cc_email in cc_list:
|
for cc_email in cc_list:
|
||||||
|
|
||||||
# Ensure that contacts on cc_list will be notified on the same email (index 0)
|
# Ensure that contacts on cc_list will be notified on the same email (index 0)
|
||||||
#self.assertIn(cc_email, mail.outbox[0].to)
|
# self.assertIn(cc_email, mail.outbox[0].to)
|
||||||
|
|
||||||
# Ensure that <TicketCC> exists
|
# Ensure that <TicketCC> exists
|
||||||
ticket_cc = TicketCC.objects.get(ticket=ticket, email=cc_email)
|
ticket_cc = TicketCC.objects.get(ticket=ticket, email=cc_email)
|
||||||
@ -335,7 +335,6 @@ class EmailInteractionsTestCase(TestCase):
|
|||||||
self.assertTrue(ticket_cc.email, cc_email)
|
self.assertTrue(ticket_cc.email, cc_email)
|
||||||
|
|
||||||
def test_create_ticket_from_email_with_invalid_carbon_copy(self):
|
def test_create_ticket_from_email_with_invalid_carbon_copy(self):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Ensure that no <TicketCC> instance is created if an invalid element of the
|
Ensure that no <TicketCC> instance is created if an invalid element of the
|
||||||
"rfc_2822_cc" field is provided when creating a <Ticket> instance.
|
"rfc_2822_cc" field is provided when creating a <Ticket> instance.
|
||||||
@ -375,7 +374,7 @@ class EmailInteractionsTestCase(TestCase):
|
|||||||
for cc_email in cc_list:
|
for cc_email in cc_list:
|
||||||
|
|
||||||
# Ensure that contacts on cc_list will be notified on the same email (index 0)
|
# Ensure that contacts on cc_list will be notified on the same email (index 0)
|
||||||
#self.assertIn(cc_email, mail.outbox[0].to)
|
# self.assertIn(cc_email, mail.outbox[0].to)
|
||||||
|
|
||||||
# Ensure that <TicketCC> exists. Even if it's an invalid email.
|
# Ensure that <TicketCC> exists. Even if it's an invalid email.
|
||||||
ticket_cc = TicketCC.objects.get(ticket=ticket, email=cc_email)
|
ticket_cc = TicketCC.objects.get(ticket=ticket, email=cc_email)
|
||||||
@ -383,14 +382,12 @@ class EmailInteractionsTestCase(TestCase):
|
|||||||
self.assertTrue(ticket_cc.email, cc_email)
|
self.assertTrue(ticket_cc.email, cc_email)
|
||||||
|
|
||||||
def test_create_followup_from_email_with_valid_message_id_with_no_initial_cc_list(self):
|
def test_create_followup_from_email_with_valid_message_id_with_no_initial_cc_list(self):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Ensure that if a message is received with an valid In-Reply-To ID,
|
Ensure that if a message is received with an valid In-Reply-To ID,
|
||||||
the expected <TicketCC> instances are created even if the there were
|
the expected <TicketCC> instances are created even if the there were
|
||||||
no <TicketCC>s so far.
|
no <TicketCC>s so far.
|
||||||
"""
|
"""
|
||||||
|
# Ticket and TicketCCs creation #
|
||||||
### Ticket and TicketCCs creation ###
|
|
||||||
msg = email.message.Message()
|
msg = email.message.Message()
|
||||||
|
|
||||||
message_id = uuid.uuid4().hex
|
message_id = uuid.uuid4().hex
|
||||||
@ -415,13 +412,13 @@ class EmailInteractionsTestCase(TestCase):
|
|||||||
# the new and update queues (+2)
|
# the new and update queues (+2)
|
||||||
|
|
||||||
# Ensure that the submitter is notified
|
# Ensure that the submitter is notified
|
||||||
self.assertIn(submitter_email,mail.outbox[0].to)
|
self.assertIn(submitter_email, mail.outbox[0].to)
|
||||||
|
|
||||||
# As we have created an Ticket from an email, we notify the sender (+1)
|
# As we have created an Ticket from an email, we notify the sender (+1)
|
||||||
# and the new and update queues (+2)
|
# and the new and update queues (+2)
|
||||||
expected_email_count = 1 + 2
|
expected_email_count = 1 + 2
|
||||||
self.assertEqual(expected_email_count, len(mail.outbox))
|
self.assertEqual(expected_email_count, len(mail.outbox))
|
||||||
### end of the Ticket and TicketCCs creation ###
|
# end of the Ticket and TicketCCs creation #
|
||||||
|
|
||||||
# Reply message
|
# Reply message
|
||||||
reply = email.message.Message()
|
reply = email.message.Message()
|
||||||
@ -466,21 +463,19 @@ class EmailInteractionsTestCase(TestCase):
|
|||||||
# the new and update queues (+2)
|
# the new and update queues (+2)
|
||||||
|
|
||||||
# Ensure that the submitter is notified
|
# Ensure that the submitter is notified
|
||||||
#self.assertIn(submitter_email, mail.outbox[expected_email_count - 3].to)
|
# self.assertIn(submitter_email, mail.outbox[expected_email_count - 3].to)
|
||||||
|
|
||||||
# Ensure that contacts on cc_list will be notified on the same email (index 0)
|
# Ensure that contacts on cc_list will be notified on the same email (index 0)
|
||||||
#for cc_email in cc_list:
|
# for cc_email in cc_list:
|
||||||
#self.assertIn(cc_email, mail.outbox[expected_email_count - 1].to)
|
# self.assertIn(cc_email, mail.outbox[expected_email_count - 1].to)
|
||||||
|
|
||||||
def test_create_followup_from_email_with_valid_message_id_with_original_cc_list_included(self):
|
def test_create_followup_from_email_with_valid_message_id_with_original_cc_list_included(self):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Ensure that if a message is received with an valid In-Reply-To ID,
|
Ensure that if a message is received with an valid In-Reply-To ID,
|
||||||
the expected <TicketCC> instances are created but if there's any
|
the expected <TicketCC> instances are created but if there's any
|
||||||
overlap with the previous Cc list, no duplicates are created.
|
overlap with the previous Cc list, no duplicates are created.
|
||||||
"""
|
"""
|
||||||
|
# Ticket and TicketCCs creation #
|
||||||
### Ticket and TicketCCs creation ###
|
|
||||||
msg = email.message.Message()
|
msg = email.message.Message()
|
||||||
|
|
||||||
message_id = uuid.uuid4().hex
|
message_id = uuid.uuid4().hex
|
||||||
@ -514,13 +509,13 @@ class EmailInteractionsTestCase(TestCase):
|
|||||||
# the new and update queues (+2)
|
# the new and update queues (+2)
|
||||||
|
|
||||||
# Ensure that the submitter is notified
|
# Ensure that the submitter is notified
|
||||||
self.assertIn(submitter_email,mail.outbox[0].to)
|
self.assertIn(submitter_email, mail.outbox[0].to)
|
||||||
|
|
||||||
# As we have created an Ticket from an email, we notify the sender (+1)
|
# As we have created an Ticket from an email, we notify the sender (+1)
|
||||||
# and the new and update queues (+2)
|
# and the new and update queues (+2)
|
||||||
expected_email_count = 1 + 2
|
expected_email_count = 1 + 2
|
||||||
self.assertEqual(expected_email_count, len(mail.outbox))
|
self.assertEqual(expected_email_count, len(mail.outbox))
|
||||||
### end of the Ticket and TicketCCs creation ###
|
# end of the Ticket and TicketCCs creation #
|
||||||
|
|
||||||
# Reply message
|
# Reply message
|
||||||
reply = email.message.Message()
|
reply = email.message.Message()
|
||||||
@ -567,14 +562,13 @@ class EmailInteractionsTestCase(TestCase):
|
|||||||
self.assertTrue(ticket_cc.email, cc_email)
|
self.assertTrue(ticket_cc.email, cc_email)
|
||||||
|
|
||||||
def test_create_followup_from_email_with_invalid_message_id(self):
|
def test_create_followup_from_email_with_invalid_message_id(self):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Ensure that if a message is received with an invalid In-Reply-To ID and we
|
Ensure that if a message is received with an invalid In-Reply-To
|
||||||
can infer the original Ticket ID by the message's subject, the expected
|
ID and we can infer the original Ticket ID by the message's subject,
|
||||||
<TicketCC> instances are created
|
the expected <TicketCC> instances are created.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
### Ticket and TicketCCs creation ###
|
# Ticket and TicketCCs creation #
|
||||||
msg = email.message.Message()
|
msg = email.message.Message()
|
||||||
|
|
||||||
message_id = uuid.uuid4().hex
|
message_id = uuid.uuid4().hex
|
||||||
@ -611,19 +605,19 @@ class EmailInteractionsTestCase(TestCase):
|
|||||||
self.assertEqual(expected_email_count, len(mail.outbox))
|
self.assertEqual(expected_email_count, len(mail.outbox))
|
||||||
|
|
||||||
# Ensure that the submitter is notified
|
# Ensure that the submitter is notified
|
||||||
self.assertIn(submitter_email,mail.outbox[0].to)
|
self.assertIn(submitter_email, mail.outbox[0].to)
|
||||||
|
|
||||||
# Ensure that <TicketCC> is created
|
# Ensure that <TicketCC> is created
|
||||||
for cc_email in cc_list:
|
for cc_email in cc_list:
|
||||||
|
|
||||||
# Ensure that contacts on cc_list will be notified on the same email (index 0)
|
# Ensure that contacts on cc_list will be notified on the same email (index 0)
|
||||||
#self.assertIn(cc_email, mail.outbox[0].to)
|
# self.assertIn(cc_email, mail.outbox[0].to)
|
||||||
|
|
||||||
ticket_cc = TicketCC.objects.get(ticket=ticket, email=cc_email)
|
ticket_cc = TicketCC.objects.get(ticket=ticket, email=cc_email)
|
||||||
self.assertTrue(ticket_cc.ticket, ticket)
|
self.assertTrue(ticket_cc.ticket, ticket)
|
||||||
self.assertTrue(ticket_cc.email, cc_email)
|
self.assertTrue(ticket_cc.email, cc_email)
|
||||||
|
|
||||||
### end of the Ticket and TicketCCs creation ###
|
# end of the Ticket and TicketCCs creation #
|
||||||
|
|
||||||
# Reply message
|
# Reply message
|
||||||
reply = email.message.Message()
|
reply = email.message.Message()
|
||||||
@ -652,7 +646,6 @@ class EmailInteractionsTestCase(TestCase):
|
|||||||
ticket = Ticket.objects.get(id=followup.ticket.id)
|
ticket = Ticket.objects.get(id=followup.ticket.id)
|
||||||
self.assertEqual(ticket.ticket_for_url, "mq1-%s" % ticket.id)
|
self.assertEqual(ticket.ticket_for_url, "mq1-%s" % ticket.id)
|
||||||
|
|
||||||
|
|
||||||
# Ensure that <TicketCC> is created
|
# Ensure that <TicketCC> is created
|
||||||
for cc_email in cc_list:
|
for cc_email in cc_list:
|
||||||
# Even after 2 messages with the same cc_list, <get> MUST return only
|
# Even after 2 messages with the same cc_list, <get> MUST return only
|
||||||
@ -668,10 +661,10 @@ class EmailInteractionsTestCase(TestCase):
|
|||||||
self.assertEqual(email_count + 1 + 2 + 2, len(mail.outbox))
|
self.assertEqual(email_count + 1 + 2 + 2, len(mail.outbox))
|
||||||
|
|
||||||
def test_create_ticket_from_email_to_a_notification_enabled_queue(self):
|
def test_create_ticket_from_email_to_a_notification_enabled_queue(self):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Ensure that when an email is sent to a Queue with notifications_enabled turned ON,
|
Ensure that when an email is sent to a Queue with
|
||||||
and a <Ticket> is created, all contacts n the TicketCC list are notified.
|
notifications_enabled turned ON, and a <Ticket> is created, all
|
||||||
|
contacts in the TicketCC list are notified.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
msg = email.message.Message()
|
msg = email.message.Message()
|
||||||
@ -691,7 +684,6 @@ class EmailInteractionsTestCase(TestCase):
|
|||||||
email_count = len(mail.outbox)
|
email_count = len(mail.outbox)
|
||||||
object_from_message(str(msg), self.queue_public, logger=logger)
|
object_from_message(str(msg), self.queue_public, logger=logger)
|
||||||
|
|
||||||
|
|
||||||
followup = FollowUp.objects.get(message_id=message_id)
|
followup = FollowUp.objects.get(message_id=message_id)
|
||||||
ticket = Ticket.objects.get(id=followup.ticket.id)
|
ticket = Ticket.objects.get(id=followup.ticket.id)
|
||||||
self.assertEqual(ticket.ticket_for_url, "mq1-%s" % ticket.id)
|
self.assertEqual(ticket.ticket_for_url, "mq1-%s" % ticket.id)
|
||||||
@ -709,19 +701,18 @@ class EmailInteractionsTestCase(TestCase):
|
|||||||
for cc_email in cc_list:
|
for cc_email in cc_list:
|
||||||
|
|
||||||
# Ensure that contacts on cc_list will be notified on the same email (index 0)
|
# Ensure that contacts on cc_list will be notified on the same email (index 0)
|
||||||
#self.assertIn(cc_email, mail.outbox[0].to)
|
# self.assertIn(cc_email, mail.outbox[0].to)
|
||||||
|
|
||||||
ticket_cc = TicketCC.objects.get(ticket=ticket, email=cc_email)
|
ticket_cc = TicketCC.objects.get(ticket=ticket, email=cc_email)
|
||||||
self.assertTrue(ticket_cc.ticket, ticket)
|
self.assertTrue(ticket_cc.ticket, ticket)
|
||||||
self.assertTrue(ticket_cc.email, cc_email)
|
self.assertTrue(ticket_cc.email, cc_email)
|
||||||
|
|
||||||
|
|
||||||
def test_create_ticket_from_email_to_a_notification_disabled_queue(self):
|
def test_create_ticket_from_email_to_a_notification_disabled_queue(self):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Ensure that when an email is sent to a Queue with notifications_enabled turned OFF, only the
|
Ensure that when an email is sent to a Queue with notifications_enabled
|
||||||
new_ticket_cc and updated_ticket_cc contacts (if they are set) are notified. No contact
|
turned OFF, only the new_ticket_cc and updated_ticket_cc contacts (if
|
||||||
from the TicketCC list should be notified.
|
they are set) are notified. No contact from the TicketCC list should
|
||||||
|
be notified.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
msg = email.message.Message()
|
msg = email.message.Message()
|
||||||
@ -764,13 +755,12 @@ class EmailInteractionsTestCase(TestCase):
|
|||||||
self.assertTrue(ticket_cc.email, cc_email)
|
self.assertTrue(ticket_cc.email, cc_email)
|
||||||
|
|
||||||
def test_create_followup_from_email_to_a_notification_enabled_queue(self):
|
def test_create_followup_from_email_to_a_notification_enabled_queue(self):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Ensure that when an email is sent to a Queue with notifications_enabled turned ON,
|
Ensure that when an email is sent to a Queue with notifications_enabled
|
||||||
and a <FollowUp> is created, all contacts n the TicketCC list are notified.
|
turned ON, and a <FollowUp> is created, all contacts n the TicketCC
|
||||||
|
list are notified.
|
||||||
"""
|
"""
|
||||||
|
# Ticket and TicketCCs creation #
|
||||||
### Ticket and TicketCCs creation ###
|
|
||||||
msg = email.message.Message()
|
msg = email.message.Message()
|
||||||
|
|
||||||
message_id = uuid.uuid4().hex
|
message_id = uuid.uuid4().hex
|
||||||
@ -804,12 +794,12 @@ class EmailInteractionsTestCase(TestCase):
|
|||||||
for cc_email in cc_list:
|
for cc_email in cc_list:
|
||||||
|
|
||||||
# Ensure that contacts on cc_list will be notified on the same email (index 0)
|
# Ensure that contacts on cc_list will be notified on the same email (index 0)
|
||||||
#self.assertIn(cc_email, mail.outbox[0].to)
|
# self.assertIn(cc_email, mail.outbox[0].to)
|
||||||
|
|
||||||
ticket_cc = TicketCC.objects.get(ticket=ticket, email=cc_email)
|
ticket_cc = TicketCC.objects.get(ticket=ticket, email=cc_email)
|
||||||
self.assertTrue(ticket_cc.ticket, ticket)
|
self.assertTrue(ticket_cc.ticket, ticket)
|
||||||
self.assertTrue(ticket_cc.email, cc_email)
|
self.assertTrue(ticket_cc.email, cc_email)
|
||||||
### end of the Ticket and TicketCCs creation ###
|
# end of the Ticket and TicketCCs creation #
|
||||||
|
|
||||||
# Reply message
|
# Reply message
|
||||||
reply = email.message.Message()
|
reply = email.message.Message()
|
||||||
@ -842,7 +832,7 @@ class EmailInteractionsTestCase(TestCase):
|
|||||||
for cc_email in cc_list:
|
for cc_email in cc_list:
|
||||||
|
|
||||||
# Ensure that contacts on cc_list will be notified on the same email (index 0)
|
# Ensure that contacts on cc_list will be notified on the same email (index 0)
|
||||||
#self.assertIn(cc_email, mail.outbox[expected_email_count - 1].to)
|
# self.assertIn(cc_email, mail.outbox[expected_email_count - 1].to)
|
||||||
|
|
||||||
ticket_cc = TicketCC.objects.get(ticket=ticket, email=cc_email)
|
ticket_cc = TicketCC.objects.get(ticket=ticket, email=cc_email)
|
||||||
self.assertTrue(ticket_cc.ticket, ticket)
|
self.assertTrue(ticket_cc.ticket, ticket)
|
||||||
@ -853,8 +843,7 @@ class EmailInteractionsTestCase(TestCase):
|
|||||||
Ensure that when an email is sent to a Queue with notifications_enabled
|
Ensure that when an email is sent to a Queue with notifications_enabled
|
||||||
turned OFF, and a <FollowUp> is created, TicketCC is NOT notified.
|
turned OFF, and a <FollowUp> is created, TicketCC is NOT notified.
|
||||||
"""
|
"""
|
||||||
|
# Ticket and TicketCCs creation #
|
||||||
### Ticket and TicketCCs creation ###
|
|
||||||
msg = email.message.Message()
|
msg = email.message.Message()
|
||||||
|
|
||||||
message_id = uuid.uuid4().hex
|
message_id = uuid.uuid4().hex
|
||||||
@ -883,7 +872,6 @@ class EmailInteractionsTestCase(TestCase):
|
|||||||
expected_email_count = email_count + 1 + 2
|
expected_email_count = email_count + 1 + 2
|
||||||
self.assertEqual(expected_email_count, len(mail.outbox))
|
self.assertEqual(expected_email_count, len(mail.outbox))
|
||||||
|
|
||||||
|
|
||||||
# Ensure that <TicketCC> is created
|
# Ensure that <TicketCC> is created
|
||||||
for cc_email in cc_list:
|
for cc_email in cc_list:
|
||||||
|
|
||||||
@ -893,7 +881,7 @@ class EmailInteractionsTestCase(TestCase):
|
|||||||
ticket_cc = TicketCC.objects.get(ticket=ticket, email=cc_email)
|
ticket_cc = TicketCC.objects.get(ticket=ticket, email=cc_email)
|
||||||
self.assertTrue(ticket_cc.ticket, ticket)
|
self.assertTrue(ticket_cc.ticket, ticket)
|
||||||
self.assertTrue(ticket_cc.email, cc_email)
|
self.assertTrue(ticket_cc.email, cc_email)
|
||||||
### end of the Ticket and TicketCCs creation ###
|
# end of the Ticket and TicketCCs creation #
|
||||||
|
|
||||||
# Reply message
|
# Reply message
|
||||||
reply = email.message.Message()
|
reply = email.message.Message()
|
||||||
@ -920,16 +908,14 @@ class EmailInteractionsTestCase(TestCase):
|
|||||||
expected_email_count += 1
|
expected_email_count += 1
|
||||||
self.assertEqual(expected_email_count, len(mail.outbox))
|
self.assertEqual(expected_email_count, len(mail.outbox))
|
||||||
|
|
||||||
|
|
||||||
def test_create_followup_from_email_with_valid_message_id_with_original_cc_list_included(self):
|
def test_create_followup_from_email_with_valid_message_id_with_original_cc_list_included(self):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Ensure that if a message is received with an valid In-Reply-To ID,
|
Ensure that if a message is received with an valid In-Reply-To ID,
|
||||||
the expected <TicketCC> instances are created even if the there were
|
the expected <TicketCC> instances are created even if the there were
|
||||||
no <TicketCC>s so far.
|
no <TicketCC>s so far.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
### Ticket and TicketCCs creation ###
|
# Ticket and TicketCCs creation #
|
||||||
msg = email.message.Message()
|
msg = email.message.Message()
|
||||||
|
|
||||||
message_id = uuid.uuid4().hex
|
message_id = uuid.uuid4().hex
|
||||||
@ -948,7 +934,7 @@ class EmailInteractionsTestCase(TestCase):
|
|||||||
|
|
||||||
followup = FollowUp.objects.get(message_id=message_id)
|
followup = FollowUp.objects.get(message_id=message_id)
|
||||||
ticket = Ticket.objects.get(id=followup.ticket.id)
|
ticket = Ticket.objects.get(id=followup.ticket.id)
|
||||||
### end of the Ticket and TicketCCs creation ###
|
# end of the Ticket and TicketCCs creation #
|
||||||
|
|
||||||
# Reply message
|
# Reply message
|
||||||
reply = email.message.Message()
|
reply = email.message.Message()
|
||||||
|
@ -388,6 +388,7 @@ def return_ticketccstring_and_show_subscribe(user, ticket):
|
|||||||
|
|
||||||
return ticketcc_string, show_subscribe
|
return ticketcc_string, show_subscribe
|
||||||
|
|
||||||
|
|
||||||
def subscribe_to_ticket_updates(ticket, user=None, email=None, can_view=True, can_update=False):
|
def subscribe_to_ticket_updates(ticket, user=None, email=None, can_view=True, can_update=False):
|
||||||
|
|
||||||
if ticket is not None:
|
if ticket is not None:
|
||||||
@ -400,7 +401,7 @@ def subscribe_to_ticket_updates(ticket, user=None, email=None, can_view=True, ca
|
|||||||
|
|
||||||
if user is None and len(email) < 5:
|
if user is None and len(email) < 5:
|
||||||
raise ValidationError(
|
raise ValidationError(
|
||||||
_('When you add somebody on Cc, you must provide either a User or a valid email. Email: %s' %email)
|
_('When you add somebody on Cc, you must provide either a User or a valid email. Email: %s' % email)
|
||||||
)
|
)
|
||||||
|
|
||||||
ticketcc = TicketCC(
|
ticketcc = TicketCC(
|
||||||
|
Loading…
Reference in New Issue
Block a user