@@ -0,0 +1,32 @@
|
||||
import pytest
|
||||
|
||||
from accounts.models import User
|
||||
from math_life.models import MathIdentity
|
||||
from progression.models import Card, UserAbility, UserCard, UserPet
|
||||
from progression.services import initialize_math_identity
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_initialize_math_identity_重复调用保持精灵能力和人物卡唯一():
|
||||
user = User.objects.create_user(
|
||||
username="identity_user",
|
||||
password="StrongPass_2026",
|
||||
nickname="身份用户",
|
||||
)
|
||||
identity = MathIdentity.objects.create(
|
||||
code="1000",
|
||||
name="定理工匠",
|
||||
clan="信仰者",
|
||||
mathematician="高斯",
|
||||
description="严谨推导与纯粹热爱。",
|
||||
portrait="/static/img/mathematicians/1000.png",
|
||||
)
|
||||
|
||||
initialize_math_identity(user, identity)
|
||||
initialize_math_identity(user, identity)
|
||||
|
||||
assert UserPet.objects.filter(user=user).count() == 1
|
||||
assert UserAbility.objects.filter(user=user).count() == len(UserAbility.Dimension.choices)
|
||||
assert Card.objects.filter(slug="mathbti-1000").count() == 1
|
||||
assert UserCard.objects.filter(user=user, card__slug="mathbti-1000").count() == 1
|
||||
assert set(UserAbility.objects.filter(user=user).values_list("level", flat=True)) == {0}
|
||||
Reference in New Issue
Block a user