fix(douyu): 按到期时间修正精英宝典状态
This commit is contained in:
@@ -11,6 +11,9 @@ from web.backend.services.douyu_account_state import refresh_douyu_account_state
|
||||
|
||||
|
||||
class FakeClient:
|
||||
def __init__(self, *, expire_time: int = 1799999999):
|
||||
self.expire_time = expire_time
|
||||
|
||||
def acf_ccn(self, *, refresh_subscribe: bool = False):
|
||||
assert refresh_subscribe is False
|
||||
return "csrf"
|
||||
@@ -19,7 +22,7 @@ class FakeClient:
|
||||
return {
|
||||
"manual_type": 1,
|
||||
"manual_score": 5200,
|
||||
"expire_time": 1799999999,
|
||||
"expire_time": self.expire_time,
|
||||
}
|
||||
|
||||
def query_points(self, **_kwargs):
|
||||
@@ -129,3 +132,42 @@ def test_invalid_ck_writes_lifecycle_without_querying_activity(db):
|
||||
assert account.ck_check_status == "invalid"
|
||||
assert account.status == "invalid"
|
||||
assert state.elite_opened is None
|
||||
|
||||
|
||||
def test_expired_elite_is_not_currently_open(db):
|
||||
account = Account(
|
||||
username="expired-elite-account",
|
||||
password="p",
|
||||
email="expired@example.com",
|
||||
email_password="ep",
|
||||
status="active",
|
||||
ck_check_status="valid",
|
||||
cookie="acf_uid=100",
|
||||
elite_opened=True,
|
||||
elite_expire_time=1,
|
||||
auto_managed=True,
|
||||
)
|
||||
db.add(account)
|
||||
db.commit()
|
||||
|
||||
state = refresh_douyu_account_state(
|
||||
db,
|
||||
account,
|
||||
manual_id="manual",
|
||||
rid="room",
|
||||
act_alias="alias",
|
||||
client=cast(DouyuActivityClient, FakeClient(expire_time=1)),
|
||||
cookie_checker=lambda _cookie: {
|
||||
"valid": True,
|
||||
"message": "有效",
|
||||
"fish_ball": 10,
|
||||
"nickname": "测试",
|
||||
"level": 5,
|
||||
"checked_at": datetime.now(UTC),
|
||||
},
|
||||
)
|
||||
|
||||
db.refresh(account)
|
||||
assert state.elite_opened is False
|
||||
assert account.elite_opened is False
|
||||
assert account.elite_expire_time == 1
|
||||
|
||||
Reference in New Issue
Block a user