How can i use pytest for testing authenticated enpoints in FastAPI? I tried this way but doesnt work:
def test_post_create_game_with_existing_name():
login = {
"username": "Admin_1",
"password": "Admin123",
}
token = client.post("/token/", data=login)
data = {
"game_name": "Game_0",
"player_name": "Player_0",
"password": "Player123"
}
response = client.post("/game/",
headers=token,
data=data)
assert response.status_code == 403
assert response.json() == {'detail': 'Game name already exist'}
Aucun commentaire:
Enregistrer un commentaire