Skip to content

Commit

Permalink
Fix Get Profile by Identifier
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnGrubba committed Aug 24, 2024
1 parent d8cf747 commit 314e6ce
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/api/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ async def get_profile(identifier: str):
# Hide email
usr = get_public_user(usr["_id"])
usr.pop("email")
return usr
return bson_to_json(usr)


@router.post("/picture", status_code=200)
Expand Down
17 changes: 17 additions & 0 deletions src/api/profile_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,20 @@ def test_update_username_taken(fixturesessiontoken_user, fixturesessiontoken_use
)
assert response.status_code == 409
assert response.json().get("detail") == "Username already in use."


def test_get_profile_by_username(fixturesessiontoken_user, fixturesessiontoken_user2):
client.cookies.set("session", fixturesessiontoken_user[0])
response = client.get(
f"/profile/{fixturesessiontoken_user2[1]["username"]}"
)
assert response.status_code == 200
resp_json = response.json()
assert resp_json.get("username") == fixturesessiontoken_user2[1]["username"]

def test_get_profile_by_username_not_found(fixturesessiontoken_user, fixturesessiontoken_user2):
client.cookies.set("session", fixturesessiontoken_user[0])
response = client.get(
f"/profile/notexistent"
)
assert response.status_code == 404

0 comments on commit 314e6ce

Please sign in to comment.