Skip to content

Commit 54126c0

Browse files
committed
fix tests
1 parent 6a634bf commit 54126c0

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

drfpasswordless/utils.py

+5
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,11 @@ def send_sms_with_callback_token(user, mobile_token, **kwargs):
156156
"""
157157
if api_settings.PASSWORDLESS_TEST_SUPPRESSION is True:
158158
# we assume success to prevent spamming SMS during testing.
159+
160+
# even if you have suppression on– you must provide a number if you have mobile selected.
161+
if api_settings.PASSWORDLESS_MOBILE_NOREPLY_NUMBER is None:
162+
return False
163+
159164
return True
160165

161166
base_string = kwargs.get('mobile_message', api_settings.PASSWORDLESS_MOBILE_MESSAGE)

tests/test_settings.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,20 @@ def test_mobile_auth_disabled(self):
4141

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

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

5859
def test_email_only_auth_enabled(self):
5960
api_settings.PASSWORDLESS_AUTH_TYPES = ['EMAIL']

0 commit comments

Comments
 (0)