[MNT] Replace Live Server Calls with Mocks in Unit Tests
Several tests currently rely on direct connections to the live server (production/test), which can cause race conditions, server overload, and sporadic failures (see https://github.com/openml/openml-python/issues/1586). To ensure these remain true unit tests, they should use mocks/patches instead of the remote server.
Steps:
- Identify tests using the remote server, e.g., marked with
"production_server"or"test_server". - Mock or patch
requests.Sessionin tests relying onopenml._api_calls._send_request. Alternatively, higher-level mocking can be used to simplify implementation.
Affected test files (can be separate sub-tasks/PRs):
- [ ] test_datasets/test_dataset_functions.py
- [ ] test_datasets/test_dataset.py
- [ ] test_evaluations/test_evaluation_functions.py
- https://github.com/openml/openml-python/pull/1672
- [ ] test_flows/test_flow_functions.py
- https://github.com/openml/openml-python/pull/1670
- [ ] test_flows/test_flow.py
- [ ] test_openml/test_api_calls.py
- [ ] test_runs/test_run_functions.py
- [ ] test_runs/test_run.py
- [ ] test_runs/test_trace.py
- [ ] test_setups/test_setup_functions.py
- https://github.com/openml/openml-python/pull/1673
- https://github.com/openml/openml-python/pull/1674
- [ ] test_study/test_study_functions.py
- https://github.com/openml/openml-python/pull/1668
- [ ] test_tasks/test_classification_task.py
- [ ] test_tasks/test_clustering_task.py
- https://github.com/openml/openml-python/pull/1669
- [ ] test_tasks/test_learning_curve_task.py
- https://github.com/openml/openml-python/pull/1675
- [ ] test_tasks/test_regression_task.py
- [ ] test_tasks/test_supervised_task.py
- [ ] test_tasks/test_task_functions.py
- [ ] test_tasks/test_task_methods.py
- https://github.com/openml/openml-python/pull/1664
- [ ] test_tasks/test_task.py
- [ ] test_utils/test_utils.py
hi, i'll be working on test_runs/test_run.py and test_tasks/test_task.py
@geetu040
I will be working on test_tasks/test_supervised_task.py and will open a PR for it
Hi @geetu040, I would like to work on tests/test_runs/test_run.py. I'll replace the live server calls with mocks following the pattern used in other PRs for this issue.
I've gone ahead and submitted PR #1695 implementing the mocks for tests/test_runs/test_run.py. Let me know if any changes are needed!