@@ -14,7 +14,6 @@ def test_RequestInterface_download_url(
1414 mock_requests : Mock , mock_shutil : Mock , mock_open : Mock , tmp_path : str
1515) -> None :
1616 mock_requests .get .return_value .status_code = 200
17-
1817 RequestInterface .download_url (url = "foo" , name = "bar" , destination = tmp_path )
1918 mock_requests .get .assert_called_once_with (
2019 url = "foo" ,
@@ -106,3 +105,28 @@ def test_RequestInterface_with_no_trace_id(mock_requests: Mock) -> None:
106105 },
107106 json = body ,
108107 )
108+
109+
110+ def test_RequestInterface_make_header_api_key () -> None :
111+ audiostack .Authorization = "bearer_token" # type: ignore
112+ # Gets ignored if api_key is present
113+ headers = RequestInterface .make_header ()
114+ assert headers == {
115+ "x-python-sdk-version" : audiostack .sdk_version ,
116+ "x-api-key" : audiostack .api_key ,
117+ }
118+
119+
120+ def test_RequestInterface_make_header_Authorization () -> None :
121+ key = audiostack .api_key # keep the key as we will reset it after the test
122+ audiostack .api_key = None
123+ audiostack .Authorization = "bearer_token" # type: ignore
124+ headers = RequestInterface .make_header ()
125+ assert headers == {
126+ "x-python-sdk-version" : audiostack .sdk_version ,
127+ "Authorization" : "bearer_token" ,
128+ }
129+
130+ audiostack .api_key = key
131+ audiostack .Authorization = None
132+ # resetting after last test - otherwise downstream tests will fail with wrong API even if they import the API key
0 commit comments