11import uuid
22
3+ from fastapi import status
34from fastapi .testclient import TestClient
45from sqlmodel import Session
56
@@ -16,7 +17,7 @@ def test_create_item(
1617 headers = superuser_token_headers ,
1718 json = data ,
1819 )
19- assert response .status_code == 200
20+ assert response .status_code == status . HTTP_200_OK
2021 content = response .json ()
2122 assert content ["title" ] == data ["title" ]
2223 assert content ["description" ] == data ["description" ]
@@ -32,7 +33,7 @@ def test_read_item(
3233 f"{ settings .API_V1_STR } /items/{ item .id } " ,
3334 headers = superuser_token_headers ,
3435 )
35- assert response .status_code == 200
36+ assert response .status_code == status . HTTP_200_OK
3637 content = response .json ()
3738 assert content ["title" ] == item .title
3839 assert content ["description" ] == item .description
@@ -47,7 +48,7 @@ def test_read_item_not_found(
4748 f"{ settings .API_V1_STR } /items/{ uuid .uuid4 ()} " ,
4849 headers = superuser_token_headers ,
4950 )
50- assert response .status_code == 404
51+ assert response .status_code == status . HTTP_404_NOT_FOUND
5152 content = response .json ()
5253 assert content ["detail" ] == "Item not found"
5354
@@ -60,7 +61,7 @@ def test_read_item_not_enough_permissions(
6061 f"{ settings .API_V1_STR } /items/{ item .id } " ,
6162 headers = normal_user_token_headers ,
6263 )
63- assert response .status_code == 400
64+ assert response .status_code == status . HTTP_400_BAD_REQUEST
6465 content = response .json ()
6566 assert content ["detail" ] == "Not enough permissions"
6667
@@ -74,7 +75,7 @@ def test_read_items(
7475 f"{ settings .API_V1_STR } /items/" ,
7576 headers = superuser_token_headers ,
7677 )
77- assert response .status_code == 200
78+ assert response .status_code == status . HTTP_200_OK
7879 content = response .json ()
7980 assert len (content ["data" ]) >= 2
8081
@@ -89,7 +90,7 @@ def test_update_item(
8990 headers = superuser_token_headers ,
9091 json = data ,
9192 )
92- assert response .status_code == 200
93+ assert response .status_code == status . HTTP_200_OK
9394 content = response .json ()
9495 assert content ["title" ] == data ["title" ]
9596 assert content ["description" ] == data ["description" ]
@@ -106,7 +107,7 @@ def test_update_item_not_found(
106107 headers = superuser_token_headers ,
107108 json = data ,
108109 )
109- assert response .status_code == 404
110+ assert response .status_code == status . HTTP_404_NOT_FOUND
110111 content = response .json ()
111112 assert content ["detail" ] == "Item not found"
112113
@@ -121,7 +122,7 @@ def test_update_item_not_enough_permissions(
121122 headers = normal_user_token_headers ,
122123 json = data ,
123124 )
124- assert response .status_code == 400
125+ assert response .status_code == status . HTTP_400_BAD_REQUEST
125126 content = response .json ()
126127 assert content ["detail" ] == "Not enough permissions"
127128
@@ -134,7 +135,7 @@ def test_delete_item(
134135 f"{ settings .API_V1_STR } /items/{ item .id } " ,
135136 headers = superuser_token_headers ,
136137 )
137- assert response .status_code == 200
138+ assert response .status_code == status . HTTP_200_OK
138139 content = response .json ()
139140 assert content ["message" ] == "Item deleted successfully"
140141
@@ -146,7 +147,7 @@ def test_delete_item_not_found(
146147 f"{ settings .API_V1_STR } /items/{ uuid .uuid4 ()} " ,
147148 headers = superuser_token_headers ,
148149 )
149- assert response .status_code == 404
150+ assert response .status_code == status . HTTP_404_NOT_FOUND
150151 content = response .json ()
151152 assert content ["detail" ] == "Item not found"
152153
@@ -159,6 +160,6 @@ def test_delete_item_not_enough_permissions(
159160 f"{ settings .API_V1_STR } /items/{ item .id } " ,
160161 headers = normal_user_token_headers ,
161162 )
162- assert response .status_code == 400
163+ assert response .status_code == status . HTTP_400_BAD_REQUEST
163164 content = response .json ()
164165 assert content ["detail" ] == "Not enough permissions"
0 commit comments