@@ -20,7 +20,7 @@ def test_create_hero(client_with_db: TestClient, session: Session):
2020def test_create_hero_incomplete (client : TestClient ):
2121 # No secret_name
2222 response = client .post ("/heroes/" , json = {"name" : "Deadpond" })
23- assert response .status_code == 422
23+ assert response .status_code == status . HTTP_422_UNPROCESSABLE_ENTITY
2424
2525
2626def test_create_hero_invalid (client : TestClient ):
@@ -32,7 +32,7 @@ def test_create_hero_invalid(client: TestClient):
3232 "secret_name" : {"message" : "Do you wanna know my secret identity?" },
3333 },
3434 )
35- assert response .status_code == 422
35+ assert response .status_code == status . HTTP_422_UNPROCESSABLE_ENTITY
3636
3737
3838def test_read_heroes (session : Session , client_with_db : TestClient ):
@@ -45,7 +45,7 @@ def test_read_heroes(session: Session, client_with_db: TestClient):
4545 response = client_with_db .get ("/heroes/" )
4646 data = response .json ()
4747
48- assert response .status_code == 200
48+ assert response .status_code == status . HTTP_200_OK
4949
5050 assert len (data ) == 2
5151 assert data [0 ]["name" ] == hero_1 .name
@@ -66,7 +66,7 @@ def test_read_hero(session: Session, client_with_db: TestClient):
6666 response = client_with_db .get (f"/heroes/{ hero_1 .id } " )
6767 data = response .json ()
6868
69- assert response .status_code == 200
69+ assert response .status_code == status . HTTP_200_OK
7070 assert data ["name" ] == hero_1 .name
7171 assert "secret_name" not in data .keys ()
7272 assert data ["age" ] == hero_1 .age
@@ -81,7 +81,7 @@ def test_update_hero(session: Session, client_with_db: TestClient):
8181 response = client_with_db .patch (f"/heroes/{ hero_1 .id } " , json = {"name" : "Deadpuddle" })
8282 data = response .json ()
8383
84- assert response .status_code == 200
84+ assert response .status_code == status . HTTP_200_OK
8585 assert data ["name" ] == "Deadpuddle"
8686 assert "secret_name" not in data .keys ()
8787 assert data ["age" ] is None
@@ -97,7 +97,7 @@ def test_delete_hero(session: Session, client_with_db: TestClient):
9797
9898 hero_in_db = session .get (Hero , hero_1 .id )
9999
100- assert response .status_code == 200
100+ assert response .status_code == status . HTTP_200_OK
101101 assert hero_in_db is None
102102
103103
0 commit comments