Fix linting errors

This commit is contained in:
Christopher Broderick 2025-03-29 11:58:32 +00:00
parent 6c43d4c685
commit 432fe3c5e7
2 changed files with 35 additions and 1 deletions

View File

@ -617,7 +617,9 @@ def create_object_from_email_message(message, ticket_id, payload, files, logger)
new = True new = True
else: else:
# Possibly an email with no body but has an attachment # Possibly an email with no body but has an attachment
logger.debug("The QUEUE_EMAIL_BOX_UPDATE_ONLY setting is True so new ticket not created.") logger.debug(
"The QUEUE_EMAIL_BOX_UPDATE_ONLY setting is True so new ticket not created."
)
return None return None
# Old issue being re-opened # Old issue being re-opened
elif ticket.status == Ticket.CLOSED_STATUS: elif ticket.status == Ticket.CLOSED_STATUS:

View File

@ -47,6 +47,14 @@ fake_time = time.time()
class GetEmailCommonTests(TestCase): class GetEmailCommonTests(TestCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
@classmethod
def tearDownClass(cls):
super().tearDownClass()
def setUp(self): def setUp(self):
self.queue_public = Queue.objects.create(title="Test", slug="test") self.queue_public = Queue.objects.create(title="Test", slug="test")
self.logger = logging.getLogger("helpdesk") self.logger = logging.getLogger("helpdesk")
@ -484,6 +492,30 @@ class GetEmailCommonTests(TestCase):
% (email_att_filename), % (email_att_filename),
) )
@override_settings(QUEUE_EMAIL_BOX_UPDATE_ONLY=False)
def test_email_for_new_ticket_when_setting_allows_create(self):
"""
A new ticket is created by email if the QUEUE_EMAIL_BOX_UPDATE_ONLY setting is False
"""
message, _, _ = utils.generate_text_email(locale="en_GB")
ticket = helpdesk.email.extract_email_metadata(
message.as_string(), self.queue_public, self.logger
)
self.assertTrue(ticket is not None, "Ticket not created when it should be.")
@override_settings(QUEUE_EMAIL_BOX_UPDATE_ONLY=True)
def test_email_for_no_new_ticket_when_setting_only_allows_update(self):
"""
A new ticket cannot be created by email if the QUEUE_EMAIL_BOX_UPDATE_ONLY setting is True
"""
message, _, _ = utils.generate_text_email(locale="es_ES")
ticket = helpdesk.email.extract_email_metadata(
message.as_string(), self.queue_public, self.logger
)
self.assertTrue(
ticket is None, f"Ticket was created when it should not be: {ticket}"
)
class EmailTaskTests(TestCase): class EmailTaskTests(TestCase):
def setUp(self): def setUp(self):