feat(users): return otp expiry metadata

This commit is contained in:
2026-05-13 09:58:58 +03:30
parent d1c4889d22
commit f9c4c06531
3 changed files with 22 additions and 3 deletions

View File

@@ -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"},