8
8
import json
9
9
import pytest
10
10
11
- from api .models import User , UserGroup
11
+ from api .models import User , UserGroup , UserProfile
12
12
from api .db import Database
13
13
from e2e_tests .conftest import db_create
14
14
@@ -35,13 +35,15 @@ async def test_create_admin_user(test_async_client):
35
35
hashed_password = response .json ()
36
36
assert response .status_code == 200
37
37
38
+ profile = UserProfile (
39
+ username = username ,
40
+ hashed_password = hashed_password ,
41
+ groups = [UserGroup (name = "admin" )]
42
+ )
38
43
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
+ )
45
47
assert obj is not None
46
48
47
49
response = await test_async_client .post (
@@ -82,8 +84,10 @@ async def test_create_regular_user(test_async_client):
82
84
data = json .dumps ({'password' : password })
83
85
)
84
86
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 ())
87
91
88
92
response = await test_async_client .post (
89
93
"token" ,
@@ -118,9 +122,11 @@ def test_whoami(test_client):
118
122
},
119
123
)
120
124
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'
124
130
125
131
126
132
@pytest .mark .dependency (depends = ["test_create_regular_user" ])
0 commit comments