88
99
1010def test_create_item (
11- client : TestClient , superuser_token_headers : dict [str , str ]
11+ client : TestClient , superuser_auth_cookies : dict [str , str ]
1212) -> None :
1313 data = {"title" : "Foo" , "description" : "Fighters" }
1414 response = client .post (
1515 f"{ settings .API_V1_STR } /items/" ,
16- headers = superuser_token_headers ,
16+ cookies = superuser_auth_cookies ,
1717 json = data ,
1818 )
1919 assert response .status_code == 200
@@ -25,12 +25,12 @@ def test_create_item(
2525
2626
2727def test_read_item (
28- client : TestClient , superuser_token_headers : dict [str , str ], db : Session
28+ client : TestClient , superuser_auth_cookies : dict [str , str ], db : Session
2929) -> None :
3030 item = create_random_item (db )
3131 response = client .get (
3232 f"{ settings .API_V1_STR } /items/{ item .id } " ,
33- headers = superuser_token_headers ,
33+ cookies = superuser_auth_cookies ,
3434 )
3535 assert response .status_code == 200
3636 content = response .json ()
@@ -41,52 +41,52 @@ def test_read_item(
4141
4242
4343def test_read_item_not_found (
44- client : TestClient , superuser_token_headers : dict [str , str ]
44+ client : TestClient , superuser_auth_cookies : dict [str , str ]
4545) -> None :
4646 response = client .get (
4747 f"{ settings .API_V1_STR } /items/{ uuid .uuid4 ()} " ,
48- headers = superuser_token_headers ,
48+ cookies = superuser_auth_cookies ,
4949 )
5050 assert response .status_code == 404
5151 content = response .json ()
5252 assert content ["detail" ] == "Item not found"
5353
5454
5555def test_read_item_not_enough_permissions (
56- client : TestClient , normal_user_token_headers : dict [str , str ], db : Session
56+ client : TestClient , normal_user_auth_cookies : dict [str , str ], db : Session
5757) -> None :
5858 item = create_random_item (db )
5959 response = client .get (
6060 f"{ settings .API_V1_STR } /items/{ item .id } " ,
61- headers = normal_user_token_headers ,
61+ cookies = normal_user_auth_cookies ,
6262 )
6363 assert response .status_code == 400
6464 content = response .json ()
6565 assert content ["detail" ] == "Not enough permissions"
6666
6767
6868def test_read_items (
69- client : TestClient , superuser_token_headers : dict [str , str ], db : Session
69+ client : TestClient , superuser_auth_cookies : dict [str , str ], db : Session
7070) -> None :
7171 create_random_item (db )
7272 create_random_item (db )
7373 response = client .get (
7474 f"{ settings .API_V1_STR } /items/" ,
75- headers = superuser_token_headers ,
75+ cookies = superuser_auth_cookies ,
7676 )
7777 assert response .status_code == 200
7878 content = response .json ()
7979 assert len (content ["data" ]) >= 2
8080
8181
8282def test_update_item (
83- client : TestClient , superuser_token_headers : dict [str , str ], db : Session
83+ client : TestClient , superuser_auth_cookies : dict [str , str ], db : Session
8484) -> None :
8585 item = create_random_item (db )
8686 data = {"title" : "Updated title" , "description" : "Updated description" }
8787 response = client .put (
8888 f"{ settings .API_V1_STR } /items/{ item .id } " ,
89- headers = superuser_token_headers ,
89+ cookies = superuser_auth_cookies ,
9090 json = data ,
9191 )
9292 assert response .status_code == 200
@@ -98,12 +98,12 @@ def test_update_item(
9898
9999
100100def test_update_item_not_found (
101- client : TestClient , superuser_token_headers : dict [str , str ]
101+ client : TestClient , superuser_auth_cookies : dict [str , str ]
102102) -> None :
103103 data = {"title" : "Updated title" , "description" : "Updated description" }
104104 response = client .put (
105105 f"{ settings .API_V1_STR } /items/{ uuid .uuid4 ()} " ,
106- headers = superuser_token_headers ,
106+ cookies = superuser_auth_cookies ,
107107 json = data ,
108108 )
109109 assert response .status_code == 404
@@ -112,13 +112,13 @@ def test_update_item_not_found(
112112
113113
114114def test_update_item_not_enough_permissions (
115- client : TestClient , normal_user_token_headers : dict [str , str ], db : Session
115+ client : TestClient , normal_user_auth_cookies : dict [str , str ], db : Session
116116) -> None :
117117 item = create_random_item (db )
118118 data = {"title" : "Updated title" , "description" : "Updated description" }
119119 response = client .put (
120120 f"{ settings .API_V1_STR } /items/{ item .id } " ,
121- headers = normal_user_token_headers ,
121+ cookies = normal_user_auth_cookies ,
122122 json = data ,
123123 )
124124 assert response .status_code == 400
@@ -127,37 +127,37 @@ def test_update_item_not_enough_permissions(
127127
128128
129129def test_delete_item (
130- client : TestClient , superuser_token_headers : dict [str , str ], db : Session
130+ client : TestClient , superuser_auth_cookies : dict [str , str ], db : Session
131131) -> None :
132132 item = create_random_item (db )
133133 response = client .delete (
134134 f"{ settings .API_V1_STR } /items/{ item .id } " ,
135- headers = superuser_token_headers ,
135+ cookies = superuser_auth_cookies ,
136136 )
137137 assert response .status_code == 200
138138 content = response .json ()
139139 assert content ["message" ] == "Item deleted successfully"
140140
141141
142142def test_delete_item_not_found (
143- client : TestClient , superuser_token_headers : dict [str , str ]
143+ client : TestClient , superuser_auth_cookies : dict [str , str ]
144144) -> None :
145145 response = client .delete (
146146 f"{ settings .API_V1_STR } /items/{ uuid .uuid4 ()} " ,
147- headers = superuser_token_headers ,
147+ cookies = superuser_auth_cookies ,
148148 )
149149 assert response .status_code == 404
150150 content = response .json ()
151151 assert content ["detail" ] == "Item not found"
152152
153153
154154def test_delete_item_not_enough_permissions (
155- client : TestClient , normal_user_token_headers : dict [str , str ], db : Session
155+ client : TestClient , normal_user_auth_cookies : dict [str , str ], db : Session
156156) -> None :
157157 item = create_random_item (db )
158158 response = client .delete (
159159 f"{ settings .API_V1_STR } /items/{ item .id } " ,
160- headers = normal_user_token_headers ,
160+ cookies = normal_user_auth_cookies ,
161161 )
162162 assert response .status_code == 400
163163 content = response .json ()
0 commit comments