@@ -277,36 +277,55 @@ def test_properties_sets_headers(requests_mock: Mocker) -> None:
277
277
)
278
278
279
279
catalog = RestCatalog (
280
- "rest" , uri = TEST_URI , warehouse = "s3://some-bucket" , ** {"header.Content-Type" : "application/vnd.api+json" }
280
+ "rest" ,
281
+ uri = TEST_URI ,
282
+ warehouse = "s3://some-bucket" ,
283
+ ** {"header.Content-Type" : "application/vnd.api+json" , "header.Customized-Header" : "some/value" },
281
284
)
282
285
283
286
assert (
284
- catalog ._session .headers .get ("Content-type" ) == "application/vnd.api+json"
285
- ), "Expected 'Content-Type' header to be 'application/vnd.api+json'"
286
-
287
+ catalog ._session .headers .get ("Content-type" ) == "application/json"
288
+ ), "Expected 'Content-Type' default header not to be overwritten"
287
289
assert (
288
- requests_mock .last_request .headers ["Content-type" ] == "application/vnd.api+ json"
290
+ requests_mock .last_request .headers ["Content-type" ] == "application/json"
289
291
), "Config request did not include expected 'Content-Type' header"
290
292
293
+ assert (
294
+ catalog ._session .headers .get ("Customized-Header" ) == "some/value"
295
+ ), "Expected 'Customized-Header' header to be 'some/value'"
296
+ assert (
297
+ requests_mock .last_request .headers ["Customized-Header" ] == "some/value"
298
+ ), "Config request did not include expected 'Customized-Header' header"
299
+
291
300
292
301
def test_config_sets_headers (requests_mock : Mocker ) -> None :
293
302
namespace = "leden"
294
303
requests_mock .get (
295
304
f"{ TEST_URI } v1/config" ,
296
- json = {"defaults" : {"header.Content-Type" : "application/vnd.api+json" }, "overrides" : {}},
305
+ json = {
306
+ "defaults" : {"header.Content-Type" : "application/vnd.api+json" , "header.Customized-Header" : "some/value" },
307
+ "overrides" : {},
308
+ },
297
309
status_code = 200 ,
298
310
)
299
311
requests_mock .post (f"{ TEST_URI } v1/namespaces" , json = {"namespace" : [namespace ], "properties" : {}}, status_code = 200 )
300
312
catalog = RestCatalog ("rest" , uri = TEST_URI , warehouse = "s3://some-bucket" )
301
313
catalog .create_namespace (namespace )
302
314
303
315
assert (
304
- catalog ._session .headers .get ("Content-type" ) == "application/vnd.api+ json"
305
- ), "Expected 'Content-Type' header to be 'application/vnd.api+json' "
316
+ catalog ._session .headers .get ("Content-type" ) == "application/json"
317
+ ), "Expected 'Content-Type' default header not to be overwritten "
306
318
assert (
307
- requests_mock .last_request .headers ["Content-type" ] == "application/vnd.api+ json"
319
+ requests_mock .last_request .headers ["Content-type" ] == "application/json"
308
320
), "Create namespace request did not include expected 'Content-Type' header"
309
321
322
+ assert (
323
+ catalog ._session .headers .get ("Customized-Header" ) == "some/value"
324
+ ), "Expected 'Customized-Header' header to be 'some/value'"
325
+ assert (
326
+ requests_mock .last_request .headers ["Customized-Header" ] == "some/value"
327
+ ), "Create namespace request did not include expected 'Customized-Header' header"
328
+
310
329
311
330
def test_token_400 (rest_mock : Mocker ) -> None :
312
331
rest_mock .post (
0 commit comments