8
8
9
9
10
10
def test_create_item (
11
- client : TestClient , superuser_token_headers : dict [str , str ]
11
+ client : TestClient , superuser_auth_cookies : dict [str , str ]
12
12
) -> None :
13
13
data = {"title" : "Foo" , "description" : "Fighters" }
14
14
response = client .post (
15
15
f"{ settings .API_V1_STR } /items/" ,
16
- headers = superuser_token_headers ,
16
+ cookies = superuser_auth_cookies ,
17
17
json = data ,
18
18
)
19
19
assert response .status_code == 200
@@ -25,12 +25,12 @@ def test_create_item(
25
25
26
26
27
27
def 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
29
29
) -> None :
30
30
item = create_random_item (db )
31
31
response = client .get (
32
32
f"{ settings .API_V1_STR } /items/{ item .id } " ,
33
- headers = superuser_token_headers ,
33
+ cookies = superuser_auth_cookies ,
34
34
)
35
35
assert response .status_code == 200
36
36
content = response .json ()
@@ -41,52 +41,52 @@ def test_read_item(
41
41
42
42
43
43
def test_read_item_not_found (
44
- client : TestClient , superuser_token_headers : dict [str , str ]
44
+ client : TestClient , superuser_auth_cookies : dict [str , str ]
45
45
) -> None :
46
46
response = client .get (
47
47
f"{ settings .API_V1_STR } /items/{ uuid .uuid4 ()} " ,
48
- headers = superuser_token_headers ,
48
+ cookies = superuser_auth_cookies ,
49
49
)
50
50
assert response .status_code == 404
51
51
content = response .json ()
52
52
assert content ["detail" ] == "Item not found"
53
53
54
54
55
55
def 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
57
57
) -> None :
58
58
item = create_random_item (db )
59
59
response = client .get (
60
60
f"{ settings .API_V1_STR } /items/{ item .id } " ,
61
- headers = normal_user_token_headers ,
61
+ cookies = normal_user_auth_cookies ,
62
62
)
63
63
assert response .status_code == 400
64
64
content = response .json ()
65
65
assert content ["detail" ] == "Not enough permissions"
66
66
67
67
68
68
def 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
70
70
) -> None :
71
71
create_random_item (db )
72
72
create_random_item (db )
73
73
response = client .get (
74
74
f"{ settings .API_V1_STR } /items/" ,
75
- headers = superuser_token_headers ,
75
+ cookies = superuser_auth_cookies ,
76
76
)
77
77
assert response .status_code == 200
78
78
content = response .json ()
79
79
assert len (content ["data" ]) >= 2
80
80
81
81
82
82
def 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
84
84
) -> None :
85
85
item = create_random_item (db )
86
86
data = {"title" : "Updated title" , "description" : "Updated description" }
87
87
response = client .put (
88
88
f"{ settings .API_V1_STR } /items/{ item .id } " ,
89
- headers = superuser_token_headers ,
89
+ cookies = superuser_auth_cookies ,
90
90
json = data ,
91
91
)
92
92
assert response .status_code == 200
@@ -98,12 +98,12 @@ def test_update_item(
98
98
99
99
100
100
def test_update_item_not_found (
101
- client : TestClient , superuser_token_headers : dict [str , str ]
101
+ client : TestClient , superuser_auth_cookies : dict [str , str ]
102
102
) -> None :
103
103
data = {"title" : "Updated title" , "description" : "Updated description" }
104
104
response = client .put (
105
105
f"{ settings .API_V1_STR } /items/{ uuid .uuid4 ()} " ,
106
- headers = superuser_token_headers ,
106
+ cookies = superuser_auth_cookies ,
107
107
json = data ,
108
108
)
109
109
assert response .status_code == 404
@@ -112,13 +112,13 @@ def test_update_item_not_found(
112
112
113
113
114
114
def 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
116
116
) -> None :
117
117
item = create_random_item (db )
118
118
data = {"title" : "Updated title" , "description" : "Updated description" }
119
119
response = client .put (
120
120
f"{ settings .API_V1_STR } /items/{ item .id } " ,
121
- headers = normal_user_token_headers ,
121
+ cookies = normal_user_auth_cookies ,
122
122
json = data ,
123
123
)
124
124
assert response .status_code == 400
@@ -127,37 +127,37 @@ def test_update_item_not_enough_permissions(
127
127
128
128
129
129
def 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
131
131
) -> None :
132
132
item = create_random_item (db )
133
133
response = client .delete (
134
134
f"{ settings .API_V1_STR } /items/{ item .id } " ,
135
- headers = superuser_token_headers ,
135
+ cookies = superuser_auth_cookies ,
136
136
)
137
137
assert response .status_code == 200
138
138
content = response .json ()
139
139
assert content ["message" ] == "Item deleted successfully"
140
140
141
141
142
142
def test_delete_item_not_found (
143
- client : TestClient , superuser_token_headers : dict [str , str ]
143
+ client : TestClient , superuser_auth_cookies : dict [str , str ]
144
144
) -> None :
145
145
response = client .delete (
146
146
f"{ settings .API_V1_STR } /items/{ uuid .uuid4 ()} " ,
147
- headers = superuser_token_headers ,
147
+ cookies = superuser_auth_cookies ,
148
148
)
149
149
assert response .status_code == 404
150
150
content = response .json ()
151
151
assert content ["detail" ] == "Item not found"
152
152
153
153
154
154
def 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
156
156
) -> None :
157
157
item = create_random_item (db )
158
158
response = client .delete (
159
159
f"{ settings .API_V1_STR } /items/{ item .id } " ,
160
- headers = normal_user_token_headers ,
160
+ cookies = normal_user_auth_cookies ,
161
161
)
162
162
assert response .status_code == 400
163
163
content = response .json ()
0 commit comments