diff --git a/tests/unit/test_auth_bind_wechat_sync.py b/tests/unit/test_auth_bind_wechat_sync.py index 767a59451..e11a41e7f 100755 --- a/tests/unit/test_auth_bind_wechat_sync.py +++ b/tests/unit/test_auth_bind_wechat_sync.py @@ -23,7 +23,6 @@ from packages.application.auth.wechat_sync_use_case import ( WechatSyncUseCase, ) - # ── Test helpers ───────────────────────────────────────── @@ -107,11 +106,13 @@ class FakeVerificationCodeService: self.generated = [] def verify(self, recipient, code_type, code_value): - self.verified.append({ - "recipient": recipient, - "code_type": code_type, - "code_value": code_value, - }) + self.verified.append( + { + "recipient": recipient, + "code_type": code_type, + "code_value": code_value, + } + ) return self._verify_success, self._verify_error def generate(self, recipient, code_type): @@ -670,11 +671,13 @@ class TestWechatSyncUseCase: repo.find_by_wechat_unionid.return_value = None # first find_by_username returns a user (conflict), second time None (unique) call_count = {"n": 0} + def mock_find_by_username(username): call_count["n"] += 1 if call_count["n"] == 1: return FakeUser(username=username) # conflict return None # unique on second try + repo.find_by_username.side_effect = mock_find_by_username repo.save = MagicMock(side_effect=lambda u: u)