@@ -42,36 +42,41 @@ def test_client_init_params():
42
42
assert response .headers ["content-type" ] == "application/json"
43
43
json_data = response .json ()
44
44
assert json_data ["headers" ]["X-Test" ] == "test"
45
- assert json_data ["headers" ]["Cookie" ] == "ccc=ddd; cccc=dddd"
46
45
assert json_data ["headers" ]["Authorization" ] == "Basic dXNlcjpwYXNzd29yZA=="
47
46
assert json_data ["args" ] == {"x" : "aaa" , "y" : "bbb" }
47
+ # assert json_data["headers"]["Cookie"] == "ccc=ddd; cccc=dddd"
48
+ assert "ccc=ddd" in json_data ["headers" ]["Cookie" ]
49
+ assert "cccc=dddd" in json_data ["headers" ]["Cookie" ]
48
50
49
51
50
52
@retry ()
51
53
def test_client_setters ():
52
54
client = primp .Client ()
53
55
client .auth = ("user" , "password" )
54
56
client .headers = {"X-Test" : "TesT" }
55
- client .cookies = {"ccc" : "ddd" , "cccc" : "dddd" }
56
57
client .params = {"x" : "aaa" , "y" : "bbb" }
57
58
client .timeout = 20
58
59
60
+ client .set_cookies ("https://httpbin.org/anything" , {"ccc" : "ddd" , "cccc" : "dddd" })
61
+ assert client .get_cookies ("https://httpbin.org/anything" ) == {"ccc" : "ddd" , "cccc" : "dddd" }
62
+
59
63
response = client .get ("https://httpbin.org/anything" )
60
64
assert response .status_code == 200
61
65
assert response .status_code == 200
62
66
assert client .auth == ("user" , "password" )
63
67
assert client .headers == {"x-test" : "TesT" }
64
- assert client .cookies == {"ccc" : "ddd" , "cccc" : "dddd" }
65
68
assert client .params == {"x" : "aaa" , "y" : "bbb" }
66
69
assert client .timeout == 20.0
67
70
json_data = response .json ()
68
71
assert json_data ["method" ] == "GET"
69
72
assert json_data ["headers" ]["X-Test" ] == "TesT"
70
- assert json_data ["headers" ]["Cookie" ] == "ccc=ddd; cccc=dddd"
71
73
assert json_data ["headers" ]["Authorization" ] == "Basic dXNlcjpwYXNzd29yZA=="
72
74
assert json_data ["args" ] == {"x" : "aaa" , "y" : "bbb" }
73
75
assert "Basic dXNlcjpwYXNzd29yZA==" in response .text
74
76
assert b"Basic dXNlcjpwYXNzd29yZA==" in response .content
77
+ # assert json_data["headers"]["Cookie"] == "ccc=ddd; cccc=dddd"
78
+ assert "ccc=ddd" in json_data ["headers" ]["Cookie" ]
79
+ assert "cccc=dddd" in json_data ["headers" ]["Cookie" ]
75
80
76
81
77
82
@retry ()
@@ -93,11 +98,13 @@ def test_client_request_get():
93
98
json_data = response .json ()
94
99
assert json_data ["method" ] == "GET"
95
100
assert json_data ["headers" ]["X-Test" ] == "test"
96
- assert json_data ["headers" ]["Cookie" ] == "ccc=ddd; cccc=dddd"
97
101
assert json_data ["headers" ]["Authorization" ] == "Bearer bearerXXXXXXXXXXXXXXXXXXXX"
98
102
assert json_data ["args" ] == {"x" : "aaa" , "y" : "bbb" }
99
103
assert "Bearer bearerXXXXXXXXXXXXXXXXXXXX" in response .text
100
104
assert b"Bearer bearerXXXXXXXXXXXXXXXXXXXX" in response .content
105
+ # assert json_data["headers"]["Cookie"] == "ccc=ddd; cccc=dddd"
106
+ assert "ccc=ddd" in json_data ["headers" ]["Cookie" ]
107
+ assert "cccc=dddd" in json_data ["headers" ]["Cookie" ]
101
108
102
109
103
110
@retry ()
@@ -118,11 +125,13 @@ def test_client_get():
118
125
json_data = response .json ()
119
126
assert json_data ["method" ] == "GET"
120
127
assert json_data ["headers" ]["X-Test" ] == "test"
121
- assert json_data ["headers" ]["Cookie" ] == "ccc=ddd; cccc=dddd"
122
128
assert json_data ["headers" ]["Authorization" ] == "Bearer bearerXXXXXXXXXXXXXXXXXXXX"
123
129
assert json_data ["args" ] == {"x" : "aaa" , "y" : "bbb" }
124
130
assert "Bearer bearerXXXXXXXXXXXXXXXXXXXX" in response .text
125
131
assert b"Bearer bearerXXXXXXXXXXXXXXXXXXXX" in response .content
132
+ # assert json_data["headers"]["Cookie"] == "ccc=ddd; cccc=dddd"
133
+ assert "ccc=ddd" in json_data ["headers" ]["Cookie" ]
134
+ assert "cccc=dddd" in json_data ["headers" ]["Cookie" ]
126
135
127
136
128
137
@retry ()
@@ -145,10 +154,12 @@ def test_client_post_content():
145
154
json_data = response .json ()
146
155
assert json_data ["method" ] == "POST"
147
156
assert json_data ["headers" ]["X-Test" ] == "test"
148
- assert json_data ["headers" ]["Cookie" ] == "ccc=ddd; cccc=dddd"
149
157
assert json_data ["headers" ]["Authorization" ] == "Basic dXNlcjpwYXNzd29yZA=="
150
158
assert json_data ["args" ] == {"x" : "aaa" , "y" : "bbb" }
151
159
assert json_data ["data" ] == "test content"
160
+ # assert json_data["headers"]["Cookie"] == "ccc=ddd; cccc=dddd"
161
+ assert "ccc=ddd" in json_data ["headers" ]["Cookie" ]
162
+ assert "cccc=dddd" in json_data ["headers" ]["Cookie" ]
152
163
153
164
154
165
@retry ()
@@ -171,10 +182,12 @@ def test_client_post_data():
171
182
json_data = response .json ()
172
183
assert json_data ["method" ] == "POST"
173
184
assert json_data ["headers" ]["X-Test" ] == "test"
174
- assert json_data ["headers" ]["Cookie" ] == "ccc=ddd; cccc=dddd"
175
185
assert json_data ["headers" ]["Authorization" ] == "Bearer bearerXXXXXXXXXXXXXXXXXXXX"
176
186
assert json_data ["args" ] == {"x" : "aaa" , "y" : "bbb" }
177
187
assert json_data ["form" ] == {"key1" : "value1" , "key2" : "value2" }
188
+ # assert json_data["headers"]["Cookie"] == "ccc=ddd; cccc=dddd"
189
+ assert "ccc=ddd" in json_data ["headers" ]["Cookie" ]
190
+ assert "cccc=dddd" in json_data ["headers" ]["Cookie" ]
178
191
179
192
180
193
@retry ()
@@ -197,10 +210,12 @@ def test_client_post_json():
197
210
json_data = response .json ()
198
211
assert json_data ["method" ] == "POST"
199
212
assert json_data ["headers" ]["X-Test" ] == "test"
200
- assert json_data ["headers" ]["Cookie" ] == "ccc=ddd; cccc=dddd"
201
213
assert json_data ["headers" ]["Authorization" ] == "Bearer bearerXXXXXXXXXXXXXXXXXXXX"
202
214
assert json_data ["args" ] == {"x" : "aaa" , "y" : "bbb" }
203
215
assert json_data ["json" ] == data
216
+ # temp
217
+ assert "ccc=ddd" in json_data ["headers" ]["Cookie" ]
218
+ assert "cccc=dddd" in json_data ["headers" ]["Cookie" ]
204
219
205
220
206
221
@pytest .fixture (scope = "session" )
@@ -235,10 +250,12 @@ def test_client_post_files(test_files):
235
250
json_data = response .json ()
236
251
assert json_data ["method" ] == "POST"
237
252
assert json_data ["headers" ]["X-Test" ] == "test"
238
- assert json_data ["headers" ]["Cookie" ] == "ccc=ddd; cccc=dddd"
239
253
assert json_data ["headers" ]["Authorization" ] == "Bearer bearerXXXXXXXXXXXXXXXXXXXX"
240
254
assert json_data ["args" ] == {"x" : "aaa" , "y" : "bbb" }
241
255
assert json_data ["files" ] == {"file1" : "aaa111" , "file2" : "bbb222" }
256
+ # assert json_data["headers"]["Cookie"] == "ccc=ddd; cccc=dddd"
257
+ assert "ccc=ddd" in json_data ["headers" ]["Cookie" ]
258
+ assert "cccc=dddd" in json_data ["headers" ]["Cookie" ]
242
259
243
260
244
261
@retry ()
0 commit comments