@@ -65,8 +65,14 @@ def test_download_and_get_hash(self):
6565 if os .path .exists (file_path ):
6666 os .remove (file_path )
6767
68- def test_download_and_get_hash_auth_type_1 (self ):
69- mock_binary_data = b"binary data for auth type 1"
68+ def test_download_and_get_hash_auth_type_header (self ):
69+ """
70+ Test the download_and_get_hash function for authentication type 2 (headers).
71+ This test verifies that the download_and_get_hash function correctly handles authentication type 2,
72+ where the credentials are passed in the headers. It mocks the necessary components and checks that
73+ the request is made with the appropriate headers.
74+ """
75+ mock_binary_data = b"binary data for auth type 2"
7076 expected_hash = hashlib .sha256 (mock_binary_data ).hexdigest ()
7177 file_path = "test_file.txt"
7278 url = "https://test.com"
@@ -81,7 +87,7 @@ def test_download_and_get_hash_auth_type_1(self):
8187 "urllib3.PoolManager.request" , return_value = mock_response
8288 ) as mock_request :
8389 result_hash = download_and_get_hash (
84- url , file_path , "sha256" , 8192 , 1 , api_key_parameter_name , credentials
90+ url , file_path , "sha256" , 8192 , 2 , api_key_parameter_name , credentials
8591 )
8692
8793 self .assertEqual (
@@ -104,8 +110,16 @@ def test_download_and_get_hash_auth_type_1(self):
104110 if os .path .exists (file_path ):
105111 os .remove (file_path )
106112
107- def test_download_and_get_hash_auth_type_2 (self ):
108- mock_binary_data = b"binary data for auth type 2"
113+ def test_download_and_get_hash_auth_type_api_key (self ):
114+ """
115+ Test the download_and_get_hash function for authentication type 1 (API key).
116+
117+ This test verifies that the download_and_get_hash function correctly handles authentication type 1,
118+ where the credentials are passed as a query parameter in the URL. It mocks the necessary components
119+ and checks that the request is made with the appropriate URL containing the API key.
120+
121+ """
122+ mock_binary_data = b"binary data for auth type 1"
109123 expected_hash = hashlib .sha256 (mock_binary_data ).hexdigest ()
110124 file_path = "test_file.txt"
111125 base_url = "https://test.com"
@@ -126,7 +140,7 @@ def test_download_and_get_hash_auth_type_2(self):
126140 file_path ,
127141 "sha256" ,
128142 8192 ,
129- 2 ,
143+ 1 ,
130144 api_key_parameter_name ,
131145 credentials ,
132146 )
0 commit comments