Skip to content

Commit a94265f

Browse files
committed
coverage
1 parent b0eb12e commit a94265f

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

tests/no_version/test_current_user_act_ver_prof.py

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from httpx import ASGITransport
33
from httpx import AsyncClient
44

5+
from fractal_server.app.models import UserOAuth
56
from fractal_server.app.routes.auth import current_user_act
67
from fractal_server.app.routes.auth import current_user_act_ver_prof
78
from fractal_server.app.security import _create_first_user
@@ -10,7 +11,12 @@
1011
_PWD = "12345"
1112

1213

13-
async def test_current_user_act_ver_prof(app: FastAPI, client):
14+
async def test_current_user_act_ver_prof(
15+
app: FastAPI,
16+
client,
17+
local_resource_profile_db,
18+
db,
19+
):
1420
await _create_first_user(
1521
email=_EMAIL,
1622
password=_PWD,
@@ -33,16 +39,30 @@ async def test_current_user_act_ver_prof(app: FastAPI, client):
3339
# Success in GET-current-user (which depends on `current_user_act`)
3440
res = await client.get("/auth/current-user/")
3541
assert res.status_code == 200
42+
user_id = res.json()["id"]
3643
assert res.json()["email"] == _EMAIL
3744
assert res.json()["profile_id"] is None
3845

39-
# Failure in GET-current-user, if it provisionally depends on
40-
# `current_user_act_ver_prof`
4146
assert app.dependency_overrides == {}
4247
app.dependency_overrides[current_user_act] = current_user_act_ver_prof
48+
49+
# Failure in GET-current-user, if it provisionally depends on
50+
# `current_user_act_ver_prof`
4351
res = await client.get("/auth/current-user/")
4452
assert res.status_code == 403
4553
assert res.json()["detail"] == (
4654
"Forbidden access (user.is_verified=True user.profile_id=None)."
4755
)
56+
57+
# Set user.profile_id
58+
_, profile = local_resource_profile_db
59+
user = await db.get(UserOAuth, user_id)
60+
user.profile_id = profile.id
61+
db.add(user)
62+
await db.commit()
63+
await db.close()
64+
65+
res = await client.get("/auth/current-user/")
66+
assert res.status_code == 200
67+
4868
app.dependency_overrides = {}

0 commit comments

Comments
 (0)