Commit f8a3824b by Albert St. Aubin

PR updates

parent 0a8f36c3
...@@ -268,13 +268,14 @@ class TestRefundSignal(TestCase): ...@@ -268,13 +268,14 @@ class TestRefundSignal(TestCase):
body='I want a refund!', tags=None): body='I want a refund!', tags=None):
""" Call the create_zendesk_ticket function. """ """ Call the create_zendesk_ticket function. """
tags = tags or ['auto_refund'] tags = tags or ['auto_refund']
create_zendesk_ticket(name, email, subject, body, tags) return create_zendesk_ticket(name, email, subject, body, tags)
@override_settings(ZENDESK_URL=ZENDESK_URL, ZENDESK_USER=None, ZENDESK_API_KEY=None) @override_settings(ZENDESK_URL=ZENDESK_URL, ZENDESK_USER=None, ZENDESK_API_KEY=None)
def test_create_zendesk_ticket_no_settings(self): def test_create_zendesk_ticket_no_settings(self):
""" Verify the Zendesk API is not called if the settings are not all set. """ """ Verify the Zendesk API is not called if the settings are not all set. """
with mock.patch('requests.post') as mock_post: with mock.patch('requests.post') as mock_post:
self.call_create_zendesk_ticket() success = self.call_create_zendesk_ticket()
self.assertFalse(success)
self.assertFalse(mock_post.called) self.assertFalse(mock_post.called)
def test_create_zendesk_ticket_request_error(self): def test_create_zendesk_ticket_request_error(self):
...@@ -284,7 +285,8 @@ class TestRefundSignal(TestCase): ...@@ -284,7 +285,8 @@ class TestRefundSignal(TestCase):
We simply need to ensure the exception is not raised beyond the function. We simply need to ensure the exception is not raised beyond the function.
""" """
with mock.patch('requests.post', side_effect=Timeout) as mock_post: with mock.patch('requests.post', side_effect=Timeout) as mock_post:
self.call_create_zendesk_ticket() success = self.call_create_zendesk_ticket()
self.assertFalse(success)
self.assertTrue(mock_post.called) self.assertTrue(mock_post.called)
@httpretty.activate @httpretty.activate
...@@ -297,7 +299,8 @@ class TestRefundSignal(TestCase): ...@@ -297,7 +299,8 @@ class TestRefundSignal(TestCase):
subject = 'Test Ticket' subject = 'Test Ticket'
body = 'I want a refund!' body = 'I want a refund!'
tags = ['auto_refund'] tags = ['auto_refund']
self.call_create_zendesk_ticket(name, email, subject, body, tags) ticket_created = self.call_create_zendesk_ticket(name, email, subject, body, tags)
self.assertTrue(ticket_created)
last_request = httpretty.last_request() last_request = httpretty.last_request()
# Verify the headers # Verify the headers
......
...@@ -376,3 +376,4 @@ def create_zendesk_ticket(requester_name, requester_email, subject, body, tags=N ...@@ -376,3 +376,4 @@ def create_zendesk_ticket(requester_name, requester_email, subject, body, tags=N
except Exception: # pylint: disable=broad-except except Exception: # pylint: disable=broad-except
log.exception('Failed to create ticket.') log.exception('Failed to create ticket.')
return False return False
return True
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment