fix: avoid MySQL timezone dependency in billing admin

This commit is contained in:
QiuSW
2026-07-04 16:43:57 +08:00
parent fb1037933d
commit 0d6b97f44d
4 changed files with 40 additions and 4 deletions
+25
View File
@@ -10,6 +10,7 @@ from django.contrib.auth import get_user_model
from django.core.exceptions import ValidationError
from django.db import IntegrityError, OperationalError, connections, transaction
from django.test import TestCase, TransactionTestCase, override_settings
from django.urls import reverse
from django.utils import timezone
from apps.ai.models import AiModel, ModelAlias
@@ -49,6 +50,30 @@ from apps.users.models import ApiKey, UserWallet
TEST_ENCRYPTION_KEY = Fernet.generate_key().decode("ascii")
class BillingAdminTests(TestCase):
def setUp(self):
user_model = get_user_model()
self.admin_user = user_model.objects.create_superuser(
username="billing-admin",
email="billing-admin@example.com",
password="test-password",
)
self.client.force_login(self.admin_user)
def test_exchange_rate_changelist_renders_when_rates_exist(self):
ExchangeRate.objects.create(
currency="CNY",
points_per_unit=Decimal("10.0000"),
effective_from=timezone.now(),
is_active=True,
)
response = self.client.get(reverse("admin:billing_exchangerate_changelist"))
self.assertEqual(response.status_code, 200)
self.assertContains(response, "CNY")
class BillingCoreModelTests(TestCase):
def setUp(self):
suffix = uuid.uuid4().hex[:8]