Dark模式 oss存储
Deploy dev / deploy (push) Successful in 1m16s

This commit is contained in:
Azmat@qq.com
2026-09-24 18:06:00 +08:00
parent ceb5163881
commit 5dbb240b59
46 changed files with 3491 additions and 350 deletions
+17
View File
@@ -1,6 +1,8 @@
from decimal import Decimal
from unittest.mock import patch
from django.conf import settings
from django.db import IntegrityError
from django.test import TestCase
from rest_framework.test import APIClient
@@ -103,6 +105,21 @@ class SingleDeviceLoginTests(TestCase):
self.assertEqual(active.count(), 1)
self.assertEqual(active.get().user_agent, "Device B")
def test_login_succeeds_when_device_audit_write_fails(self):
"""设备审计表异常不能回滚已经签发的登录 Token。"""
with patch(
"apps.accounts.views.LoginSession.objects.create",
side_effect=IntegrityError("device audit unavailable"),
):
response = APIClient().post(
"/api/auth/login/",
{"username": self.user.username, "password": "strong-password"},
format="json",
)
self.assertEqual(response.status_code, 200)
self.assertIn("token", response.data)
class InvitationFlowTests(TestCase):
def _register(self, client, username, **extra):