MCPcopy Create free account
hub / github.com/0010aor/FlashNotes / test_register_user

Function test_register_user

backend/tests/users/test_api.py:61–78  ·  view source on GitHub ↗
(client: TestClient, db: Session)

Source from the content-addressed store, hash-verified

59
60
61def test_register_user(client: TestClient, db: Session) -> None:
62 with patch("src.core.config.settings.USERS_OPEN_REGISTRATION", True):
63 username = random_email()
64 password = random_lower_string()
65 data = {"email": username, "password": password}
66 r = client.post(
67 f"{settings.API_V1_STR}/users",
68 json=data,
69 )
70 assert r.status_code == 200
71 created_user = r.json()
72 assert created_user["email"] == username
73
74 user_query = select(User).where(User.email == username)
75 user_db = db.exec(user_query).first()
76 assert user_db
77 assert user_db.email == username
78 assert verify_password(password, user_db.hashed_password)
79
80
81def test_register_user_forbidden_error(client: TestClient) -> None:

Callers

nothing calls this directly

Calls 3

random_emailFunction · 0.90
random_lower_stringFunction · 0.90
verify_passwordFunction · 0.90

Tested by

no test coverage detected