Skip to content

Commit aa6a165

Browse files
Jeny Sadadiagctucker
Jeny Sadadia
authored andcommitted
tests/e2e_tests: update e2e tests with user profile
Update e2e tests to accommodate changes in the `User` field related to user profile. Signed-off-by: Jeny Sadadia <jeny.sadadia@collabora.com>
1 parent e5225d4 commit aa6a165

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

tests/e2e_tests/test_user_creation.py

+18-12
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import json
99
import pytest
1010

11-
from api.models import User, UserGroup
11+
from api.models import User, UserGroup, UserProfile
1212
from api.db import Database
1313
from e2e_tests.conftest import db_create
1414

@@ -35,13 +35,15 @@ async def test_create_admin_user(test_async_client):
3535
hashed_password = response.json()
3636
assert response.status_code == 200
3737

38+
profile = UserProfile(
39+
username=username,
40+
hashed_password=hashed_password,
41+
groups=[UserGroup(name="admin")]
42+
)
3843
obj = await db_create(
39-
Database.COLLECTIONS[User],
40-
User(
41-
username=username,
42-
hashed_password=hashed_password,
43-
groups=[UserGroup(name="admin")]
44-
))
44+
Database.COLLECTIONS[User],
45+
User(profile=profile)
46+
)
4547
assert obj is not None
4648

4749
response = await test_async_client.post(
@@ -82,8 +84,10 @@ async def test_create_regular_user(test_async_client):
8284
data=json.dumps({'password': password})
8385
)
8486
assert response.status_code == 200
85-
assert ('id', 'username', 'hashed_password', 'active',
86-
'groups') == tuple(response.json().keys())
87+
assert ('id', 'active',
88+
'profile') == tuple(response.json().keys())
89+
assert ('username', 'hashed_password',
90+
'groups') == tuple(response.json()['profile'].keys())
8791

8892
response = await test_async_client.post(
8993
"token",
@@ -118,9 +122,11 @@ def test_whoami(test_client):
118122
},
119123
)
120124
assert response.status_code == 200
121-
assert ('id', 'username', 'hashed_password', 'active',
122-
'groups') == tuple(response.json().keys())
123-
assert response.json()['username'] == 'test_user'
125+
assert ('id', 'active',
126+
'profile') == tuple(response.json().keys())
127+
assert ('username', 'hashed_password',
128+
'groups') == tuple(response.json()['profile'].keys())
129+
assert response.json()['profile']['username'] == 'test_user'
124130

125131

126132
@pytest.mark.dependency(depends=["test_create_regular_user"])

0 commit comments

Comments
 (0)