Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronn committed Apr 17, 2020
1 parent 6a634bf commit 54126c0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
5 changes: 5 additions & 0 deletions drfpasswordless/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,11 @@ def send_sms_with_callback_token(user, mobile_token, **kwargs):
"""
if api_settings.PASSWORDLESS_TEST_SUPPRESSION is True:
# we assume success to prevent spamming SMS during testing.

# even if you have suppression on– you must provide a number if you have mobile selected.
if api_settings.PASSWORDLESS_MOBILE_NOREPLY_NUMBER is None:
return False

return True

base_string = kwargs.get('mobile_message', api_settings.PASSWORDLESS_MOBILE_MESSAGE)
Expand Down
9 changes: 5 additions & 4 deletions tests/test_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,20 @@ def test_mobile_auth_disabled(self):

def test_email_sender_required(self):
"""
Check to make sure user has a send address if email is selected.
This tests if a noreply email address has been set in settings.
"""
api_settings.PASSWORDLESS_AUTH_TYPES = ['EMAIL']
email_response = self.client.post(self.email_url, self.email_data)
self.assertEqual(email_response.status_code, status.HTTP_400_BAD_REQUEST)

def test_mobile_sender_required(self):
"""
Check to make sure user has a send address if mobile is selected.
Check to make sure user has a noreply mobile address is set.
Even if you have suppression on, you must provide some kind of sender number if mobile is selected.
"""
api_settings.PASSWORDLESS_AUTH_TYPES = ['MOBILE']
email_response = self.client.post(self.mobile_url, self.mobile_data)
self.assertEqual(email_response.status_code, status.HTTP_400_BAD_REQUEST)
mobile_response = self.client.post(self.mobile_url, self.mobile_data)
self.assertEqual(mobile_response.status_code, status.HTTP_400_BAD_REQUEST)

def test_email_only_auth_enabled(self):
api_settings.PASSWORDLESS_AUTH_TYPES = ['EMAIL']
Expand Down

0 comments on commit 54126c0

Please sign in to comment.