Skip to content

Commit dd5032b

Browse files
committed
Clean up current-user dependencies / tests
1 parent 20d35eb commit dd5032b

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

tests/fixtures_server.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ async def __aenter__(self):
349349
await db.refresh(resource)
350350
db.expunge(resource)
351351
profile = Profile(
352-
username="test01",
352+
username="fake-username",
353353
resource_id=resource.id,
354354
name="local_resource_profile_objects",
355355
resource_type=ResourceType.LOCAL,
@@ -363,7 +363,6 @@ async def __aenter__(self):
363363
# Create new user
364364
default_user_kwargs.update(self.user_kwargs)
365365
self.user = UserOAuth(**default_user_kwargs)
366-
367366
db.add(self.user)
368367
await db.commit()
369368
await db.refresh(self.user)

tests/no_version/test_current_user_act_ver_prof.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ async def test_current_user_act_ver_prof(app: FastAPI, client):
1515
email=_EMAIL,
1616
password=_PWD,
1717
is_superuser=False,
18+
is_verified=True,
1819
project_dir="/fake",
1920
)
2021
async with AsyncClient(
@@ -32,6 +33,7 @@ async def test_current_user_act_ver_prof(app: FastAPI, client):
3233
# Success in GET-current-user (which depends on `current_user_act`)
3334
res = await client.get("/auth/current-user/")
3435
assert res.status_code == 200
36+
assert res.json()["email"] == _EMAIL
3537
assert res.json()["profile_id"] is None
3638

3739
# Failure in GET-current-user, if it provisionally depends on
@@ -40,4 +42,7 @@ async def test_current_user_act_ver_prof(app: FastAPI, client):
4042
app.dependency_overrides[current_user_act] = current_user_act_ver_prof
4143
res = await client.get("/auth/current-user/")
4244
assert res.status_code == 403
45+
assert res.json()["detail"] == (
46+
"Forbidden access (user.is_verified=True user.profile_id=None)."
47+
)
4348
app.dependency_overrides = {}

0 commit comments

Comments
 (0)