feat(users): return otp expiry metadata
This commit is contained in:
@@ -53,6 +53,11 @@ class UserApiViewTests(APITestCase):
|
||||
|
||||
@patch("apps.users.api.views.generate_and_send_otp")
|
||||
def test_send_otp_view_validates_and_dispatches(self, generate_and_send_otp):
|
||||
generate_and_send_otp.return_value = {
|
||||
"detail": "OTP sent successfully",
|
||||
"expires_in_seconds": 120,
|
||||
"expires_at": "2026-05-12T10:00:00+03:30",
|
||||
}
|
||||
response = self.client.post(
|
||||
"/api/users/otp/send/",
|
||||
{"mobile": "09123330009", "mode": "login"},
|
||||
@@ -60,6 +65,7 @@ class UserApiViewTests(APITestCase):
|
||||
)
|
||||
|
||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||
self.assertEqual(response.data["expires_in_seconds"], 120)
|
||||
generate_and_send_otp.assert_called_once_with(
|
||||
mobile="09123330009",
|
||||
mode="login",
|
||||
@@ -67,6 +73,11 @@ class UserApiViewTests(APITestCase):
|
||||
|
||||
@patch("apps.users.api.views.generate_and_send_otp")
|
||||
def test_send_otp_view_supports_forget_password_mode(self, generate_and_send_otp):
|
||||
generate_and_send_otp.return_value = {
|
||||
"detail": "OTP sent successfully",
|
||||
"expires_in_seconds": 120,
|
||||
"expires_at": "2026-05-12T10:00:00+03:30",
|
||||
}
|
||||
response = self.client.post(
|
||||
"/api/users/otp/send/",
|
||||
{"mobile": "09123330001", "mode": "forget_password"},
|
||||
|
||||
Reference in New Issue
Block a user