|
29 | 29 | import openml |
30 | 30 | import openml.exceptions |
31 | 31 | import openml.utils |
32 | | -from openml._api_calls import _perform_api_call |
33 | | -from openml.testing import SimpleImputer, TestBase |
| 32 | +import requests |
| 33 | +from openml.testing import SimpleImputer, TestBase, create_request_response |
34 | 34 |
|
35 | 35 |
|
36 | 36 |
|
@@ -133,7 +133,7 @@ def test_from_xml_to_xml(self): |
133 | 133 | 7, |
134 | 134 | 9, |
135 | 135 | ]: |
136 | | - flow_xml = _perform_api_call("flow/%d" % flow_id, request_method="get") |
| 136 | + flow_xml = openml.config.get_backend().http_client.get(f"flow/{flow_id}").text |
137 | 137 | flow_dict = xmltodict.parse(flow_xml) |
138 | 138 |
|
139 | 139 | flow = openml.OpenMLFlow._from_dict(flow_dict) |
@@ -302,19 +302,22 @@ def test_semi_legal_flow(self): |
302 | 302 | @pytest.mark.sklearn() |
303 | 303 | @mock.patch("openml.flows.functions.get_flow") |
304 | 304 | @mock.patch("openml.flows.functions.flow_exists") |
305 | | - def test_publish_error(self, api_call_mock, flow_exists_mock, get_flow_mock): |
| 305 | + @mock.patch("requests.Session.request") |
| 306 | + def test_publish_error(self, mock_request, flow_exists_mock, get_flow_mock): |
306 | 307 | model = sklearn.ensemble.RandomForestClassifier() |
307 | 308 | flow = self.extension.model_to_flow(model) |
308 | | - api_call_mock.return_value = ( |
309 | | - "<oml:upload_flow>\n" " <oml:id>1</oml:id>\n" "</oml:upload_flow>" |
| 309 | + mock_request.return_value = create_request_response( |
| 310 | + status_code=200, |
| 311 | + content=( |
| 312 | + "<oml:upload_flow>\n" " <oml:id>1</oml:id>\n" "</oml:upload_flow>" |
| 313 | + ), |
310 | 314 | ) |
311 | | - flow_exists_mock.return_value = False |
312 | 315 | get_flow_mock.return_value = flow |
313 | 316 |
|
314 | 317 | flow.publish() |
315 | 318 | # Not collecting flow_id for deletion since this is a test for failed upload |
316 | 319 |
|
317 | | - assert api_call_mock.call_count == 1 |
| 320 | + assert mock_request.call_count == 1 |
318 | 321 | assert get_flow_mock.call_count == 1 |
319 | 322 | assert flow_exists_mock.call_count == 1 |
320 | 323 |
|
|
0 commit comments