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

Function test_get_existing_user_current_user

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

Source from the content-addressed store, hash-verified

36
37
38def test_get_existing_user_current_user(client: TestClient, db: Session) -> None:
39 username = random_email()
40 password = random_lower_string()
41 user_in = UserCreate(email=username, password=password)
42 services.create_user(session=db, user_create=user_in)
43
44 login_data = {
45 "username": username,
46 "password": password,
47 }
48 r = client.post(f"{settings.API_V1_STR}/tokens", data=login_data)
49 tokens = r.json()
50 a_token = tokens["access_token"]
51 headers = {"Authorization": f"Bearer {a_token}"}
52
53 r = client.get(f"{settings.API_V1_STR}/users/me", headers=headers)
54 assert 200 <= r.status_code < 300
55 api_user = r.json()
56 existing_user = services.get_user_by_email(session=db, email=username)
57 assert existing_user
58 assert existing_user.email == api_user["email"]
59
60
61def test_register_user(client: TestClient, db: Session) -> None:

Callers

nothing calls this directly

Calls 3

random_emailFunction · 0.90
random_lower_stringFunction · 0.90
UserCreateClass · 0.90

Tested by

no test coverage detected