@@ -26,28 +26,28 @@ def sample_path() -> str:
2626
2727
2828@pytest .fixture
29- def sample_url (sample_path ) -> str :
30- return urljoin (openml . config . server , sample_path )
29+ def sample_url_v1 (sample_path , test_server_v1 ) -> str :
30+ return urljoin (test_server_v1 , sample_path )
3131
3232
3333@pytest .fixture
34- def sample_download_url ( ) -> str :
35- server = openml . config . server .split ("api/" )[0 ]
34+ def sample_download_url_v1 ( test_server_v1 ) -> str :
35+ server = test_server_v1 .split ("api/" )[0 ]
3636 endpoint = "data/v1/download/1/anneal.arff"
3737 url = server + endpoint
3838 return url
3939
4040
41- def test_cache (cache , sample_url ):
41+ def test_cache (cache , sample_url_v1 ):
4242 params = {"param1" : "value1" , "param2" : "value2" }
4343
44- parsed_url = urlparse (sample_url )
44+ parsed_url = urlparse (sample_url_v1 )
4545 netloc_parts = parsed_url .netloc .split ("." )[::- 1 ]
4646 path_parts = parsed_url .path .strip ("/" ).split ("/" )
4747 params_key = "&" .join ([f"{ k } ={ v } " for k , v in params .items ()])
4848
4949
50- key = cache .get_key (sample_url , params )
50+ key = cache .get_key (sample_url_v1 , params )
5151
5252 expected_key = os .path .join (
5353 * netloc_parts ,
@@ -58,10 +58,10 @@ def test_cache(cache, sample_url):
5858 assert key == expected_key
5959
6060 # mock response
61- req = Request ("GET" , sample_url ).prepare ()
61+ req = Request ("GET" , sample_url_v1 ).prepare ()
6262 response = Response ()
6363 response .status_code = 200
64- response .url = sample_url
64+ response .url = sample_url_v1
6565 response .reason = "OK"
6666 response ._content = b"<xml>test</xml>"
6767 response .headers = {"Content-Type" : "text/xml" }
@@ -73,7 +73,7 @@ def test_cache(cache, sample_url):
7373 cached = cache .load (key )
7474
7575 assert cached .status_code == 200
76- assert cached .url == sample_url
76+ assert cached .url == sample_url_v1
7777 assert cached .content == b"<xml>test</xml>"
7878 assert cached .headers ["Content-Type" ] == "text/xml"
7979
@@ -87,13 +87,13 @@ def test_get(http_client):
8787
8888
8989@pytest .mark .uses_test_server ()
90- def test_get_with_cache_creates_cache (http_client , cache , sample_url , sample_path ):
90+ def test_get_with_cache_creates_cache (http_client , cache , sample_url_v1 , sample_path ):
9191 response = http_client .get (sample_path , enable_cache = True )
9292
9393 assert response .status_code == 200
9494 assert cache .path .exists ()
9595
96- cache_key = cache .get_key (sample_url , {})
96+ cache_key = cache .get_key (sample_url_v1 , {})
9797 cache_path = cache ._key_to_path (cache_key )
9898
9999 assert (cache_path / "meta.json" ).exists ()
@@ -102,8 +102,8 @@ def test_get_with_cache_creates_cache(http_client, cache, sample_url, sample_pat
102102
103103
104104@pytest .mark .uses_test_server ()
105- def test_get_uses_cached_response (http_client , cache , sample_url , sample_path ):
106- key = cache .get_key (sample_url , {})
105+ def test_get_uses_cached_response (http_client , cache , sample_url_v1 , sample_path ):
106+ key = cache .get_key (sample_url_v1 , {})
107107 meta_path = cache ._key_to_path (key ) / "meta.json"
108108
109109 r1 = http_client .get (sample_path , enable_cache = True )
@@ -118,8 +118,8 @@ def test_get_uses_cached_response(http_client, cache, sample_url, sample_path):
118118
119119
120120@pytest .mark .uses_test_server ()
121- def test_get_refresh_cache (http_client , cache , sample_url , sample_path ):
122- key = cache .get_key (sample_url , {})
121+ def test_get_refresh_cache (http_client , cache , sample_url_v1 , sample_path ):
122+ key = cache .get_key (sample_url_v1 , {})
123123 meta_path = cache ._key_to_path (key ) / "meta.json"
124124
125125 r1 = http_client .get (sample_path , enable_cache = True )
@@ -148,9 +148,9 @@ def test_get_without_api_key_raises(http_client):
148148
149149
150150@pytest .mark .uses_test_server ()
151- def test_download_creates_file (http_client , sample_download_url ):
151+ def test_download_creates_file (http_client , sample_download_url_v1 ):
152152 path = http_client .download (
153- url = sample_download_url ,
153+ url = sample_download_url_v1 ,
154154 file_name = "downloaded.bin" ,
155155 )
156156
@@ -160,15 +160,15 @@ def test_download_creates_file(http_client, sample_download_url):
160160
161161
162162@pytest .mark .uses_test_server ()
163- def test_download_is_cached_on_disk (http_client , sample_download_url ):
163+ def test_download_is_cached_on_disk (http_client , sample_download_url_v1 ):
164164 path1 = http_client .download (
165- url = sample_download_url ,
165+ url = sample_download_url_v1 ,
166166 file_name = "cached.bin" ,
167167 )
168168 mtime1 = path1 .stat ().st_mtime
169169
170170 path2 = http_client .download (
171- url = sample_download_url ,
171+ url = sample_download_url_v1 ,
172172 file_name = "cached.bin" ,
173173 )
174174 mtime2 = path2 .stat ().st_mtime
@@ -178,13 +178,13 @@ def test_download_is_cached_on_disk(http_client, sample_download_url):
178178
179179
180180@pytest .mark .uses_test_server ()
181- def test_download_respects_custom_handler (http_client , sample_download_url ):
181+ def test_download_respects_custom_handler (http_client , sample_download_url_v1 ):
182182 def handler (response , path : Path , encoding : str ):
183183 path .write_text ("HANDLED" , encoding = encoding )
184184 return path
185185
186186 path = http_client .download (
187- url = sample_download_url ,
187+ url = sample_download_url_v1 ,
188188 file_name = "handler.bin" ,
189189 handler = handler ,
190190 )
@@ -193,7 +193,7 @@ def handler(response, path: Path, encoding: str):
193193 assert path .read_text () == "HANDLED"
194194
195195
196- def test_post (http_client ):
196+ def test_post (http_client , test_server_v1 , test_apikey_v1 ):
197197 resource_name = "resource"
198198 resource_files = {"description" : "Resource Description File" }
199199
@@ -205,15 +205,15 @@ def test_post(http_client):
205205
206206 mock_request .assert_called_once_with (
207207 method = "POST" ,
208- url = urljoin (openml . config . server , resource_name ),
208+ url = urljoin (test_server_v1 , resource_name ),
209209 params = {},
210- data = {"api_key" : openml . config . apikey },
210+ data = {"api_key" : test_apikey_v1 },
211211 headers = openml .config ._HEADERS ,
212212 files = resource_files ,
213213 )
214214
215215
216- def test_delete (http_client ):
216+ def test_delete (http_client , test_server_v1 , test_apikey_v1 ):
217217 resource_name = "resource"
218218 resource_id = 123
219219
@@ -226,12 +226,12 @@ def test_delete(http_client):
226226 mock_request .assert_called_once_with (
227227 method = "DELETE" ,
228228 url = (
229- openml . config . server
229+ test_server_v1
230230 + resource_name
231231 + "/"
232232 + str (resource_id )
233233 ),
234- params = {"api_key" : openml . config . apikey },
234+ params = {"api_key" : test_apikey_v1 },
235235 data = {},
236236 headers = openml .config ._HEADERS ,
237237 files = None ,
0 commit comments