openml-python icon indicating copy to clipboard operation
openml-python copied to clipboard

[MNT] Replace live server calls with mocks in test_task_methods.py

Open Sandipmandal25 opened this issue 9 months ago • 1 comments

Metadata

  • Reference Issue: Fixes #1649 (tests/test_tasks/test_task_methods.py)
  • New Tests Added: No
  • Documentation Updated: No
  • Change Log Entry: "Replace live server calls with mocks in test_task_methods.py"

Details

Both tests in OpenMLTaskMethodsTest previously required a running test server. This PR removes those dependencies:

  • test_tagging — patches requests.Session.post to return mock XML responses for task/tag and task/untag endpoints; asserts the HTTP call was made with the correct URL, data, and headers via mock_post.assert_called_once_with(...). No network calls required.

  • test_get_train_and_test_split_indices — uses the static cache (task 1882 + dataset 2 already present); no network calls. Also modernises assertRaisesRegex → pytest.raises for consistency with the rest of the test suite.

Test Run

platform darwin -- Python 3.13.3, pytest-9.0.2
tests/test_tasks/test_task_methods.py::OpenMLTaskMethodsTest::test_get_train_and_test_split_indices PASSED
tests/test_tasks/test_task_methods.py::OpenMLTaskMethodsTest::test_tagging PASSED

2 passed in 0.25s

Sandipmandal25 avatar Feb 19 '26 21:02 Sandipmandal25

hey @geetu040 any update in this pr? thanks!

Sandipmandal25 avatar Feb 28 '26 18:02 Sandipmandal25