Closed uktamjon-komilov closed 11 months ago
In tests.py
you should be able to simply do something like
from dynamic_preferences_registry import global_preferences
class UserRegistrationLoginViewTestCase(APITestCase):
def test_create_user_with_otp_enabled(self):
global_preferences['authentication__registration_otp_enabled'] = True
response = self.client.post(self.url, data=self.valid_payload)
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertTrue("message" in response.data)
def test_create_user_with_otp_disabled(self):
global_preferences['authentication__registration_otp_enabled'] = False
response = self.client.post(self.url, data=self.valid_payload)
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
self.assertTrue("access" in response.data)
Can you please try that and let me know if it works for you?
Closing because of inactivity, feel free to reopen if my suggestion doesn't work
dynamic_preferences_registry.py:
serializers.py:
views.py:
tests.py:
How to mock global preferences when testing OTP enabled and disabled situations in the last tests?