@@ -217,6 +217,45 @@ def test_post_data_to_endpoint_error_handling(self):
217
217
assert exc .url == self .dar_url [:- 1 ] + endpoint
218
218
assert exc .response == sess .http .post ()
219
219
220
+ def test_post_to_url (self ):
221
+ for allowed_status_code in range (200 , 300 ):
222
+ sess = self ._prepare ()
223
+ sess .http .post .return_value .status_code = allowed_status_code
224
+
225
+ url = self .dar_url [:- 1 ] + "/data-manager/api/v3/datasetSchemas/"
226
+
227
+ payload = {"a" : 1 , "b" : "ok!" }
228
+
229
+ response = sess .post_to_url (url = url , payload = payload )
230
+
231
+ expected_http_call = call (
232
+ url ,
233
+ headers = self .expected_headers ,
234
+ json = payload ,
235
+ )
236
+ assert getattr (sess .http , "post" ).call_args_list == [expected_http_call ]
237
+ assert response == sess .http .post .return_value
238
+
239
+ def test_post_to_url_with_retry (self ):
240
+ for allowed_status_code in range (200 , 300 ):
241
+ sess = self ._prepare ()
242
+ sess .http_post_retry .post .return_value .status_code = allowed_status_code
243
+
244
+ url = self .dar_url [:- 1 ] + "/data-manager/api/v3/datasetSchemas/"
245
+
246
+ payload = {"a" : 1 , "b" : "ok!" }
247
+
248
+ response = sess .post_to_url (url = url , payload = payload , retry = True )
249
+ expected_http_call = call (
250
+ url ,
251
+ headers = self .expected_headers ,
252
+ json = payload ,
253
+ )
254
+ assert getattr (sess .http_post_retry , "post" ).call_args_list == [
255
+ expected_http_call
256
+ ]
257
+ assert response == sess .http_post_retry .post .return_value
258
+
220
259
def _assert (self , sess , method , endpoint ):
221
260
# Validate test-internal assumption
222
261
assert self .dar_url [- 1 ] == "/"
0 commit comments