Skip to content

Commit c7d9fe5

Browse files
committed
correct the tests
1 parent 0c480da commit c7d9fe5

1 file changed

Lines changed: 11 additions & 8 deletions

File tree

tests/test_flows/test_flow.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
import openml
3030
import openml.exceptions
3131
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
3434

3535

3636

@@ -133,7 +133,7 @@ def test_from_xml_to_xml(self):
133133
7,
134134
9,
135135
]:
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
137137
flow_dict = xmltodict.parse(flow_xml)
138138

139139
flow = openml.OpenMLFlow._from_dict(flow_dict)
@@ -302,19 +302,22 @@ def test_semi_legal_flow(self):
302302
@pytest.mark.sklearn()
303303
@mock.patch("openml.flows.functions.get_flow")
304304
@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):
306307
model = sklearn.ensemble.RandomForestClassifier()
307308
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+
),
310314
)
311-
flow_exists_mock.return_value = False
312315
get_flow_mock.return_value = flow
313316

314317
flow.publish()
315318
# Not collecting flow_id for deletion since this is a test for failed upload
316319

317-
assert api_call_mock.call_count == 1
320+
assert mock_request.call_count == 1
318321
assert get_flow_mock.call_count == 1
319322
assert flow_exists_mock.call_count == 1
320323

0 commit comments

Comments
 (0)