File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -37,17 +37,28 @@ async def test_add_user(client: AsyncClient):
3737
3838# TODO: parametrize test with diff urls including 404 and 401
3939async def test_get_token (client : AsyncClient ):
40- payload = {"email" : "joe@grillazz.com" , "password" : "s1lly" }
40+ # First, create the user required for this test
41+ user_payload = {
42+ "email" : "joe@grillazz.com" ,
43+ "first_name" : "Joe" ,
44+ "last_name" : "Garcia" ,
45+ "password" : "s1lly" ,
46+ }
47+ create_user_response = await client .post ("/user/" , json = user_payload )
48+ assert create_user_response .status_code == status .HTTP_201_CREATED
49+
50+ # Now, request the token for the newly created user
51+ token_payload = {"email" : "joe@grillazz.com" , "password" : "s1lly" }
4152 response = await client .post (
4253 "/user/token" ,
43- data = payload ,
54+ data = token_payload ,
4455 headers = {"Content-Type" : "application/x-www-form-urlencoded" },
4556 )
4657 assert response .status_code == status .HTTP_201_CREATED
4758 claimset = jwt .decode (
4859 response .json ()["access_token" ], options = {"verify_signature" : False }
4960 )
50- assert claimset ["email" ] == payload ["email" ]
61+ assert claimset ["email" ] == token_payload ["email" ]
5162 assert claimset ["expiry" ] == IsPositiveFloat ()
5263 assert claimset ["platform" ] == "python-httpx/0.28.1"
5364
You can’t perform that action at this time.
0 commit comments