feat: /signup returns access_token

This commit is contained in:
2026-09-04 21:21:20 +07:00
parent 27e2f58956
commit 429c961ace
4 changed files with 27 additions and 20 deletions

View File

@@ -49,15 +49,17 @@ def test_signup_rejects_weak_password(client):
def test_signup_accepts_unknown_referral_code(client):
created_user = SimpleNamespace(
username="alice", telegram_id=None, referal_code="new-code", balance=0
id=1, username="alice", telegram_id=None, referal_code="new-code", balance=0
)
repository = SimpleNamespace(
get_user_by_username=AsyncMock(return_value=None),
get_user_by_ref_code=AsyncMock(return_value=None),
create=AsyncMock(return_value=created_user),
)
sessions_repository = SimpleNamespace(create=AsyncMock(return_value=None))
with (
patch("routes.auth.UserRepository", return_value=repository),
patch("routes.auth.SessionsRepository", return_value=sessions_repository),
patch("routes.auth.estimate_password_strength", return_value=True),
patch("routes.auth.hash_password", return_value="hashed"),
):
@@ -71,11 +73,11 @@ def test_signup_accepts_unknown_referral_code(client):
},
)
assert response.status_code == 201
assert response.status_code == 200
repository.create.assert_awaited_once_with(
username="alice", hashed_password="hashed", referal_id=None
)
assert response.json()["referal_code"] == "new-code"
assert response.json()["user"]["referal_code"] == "new-code"
def test_login_distinguishes_unknown_user_and_bad_password(client):