[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 would like to work on this issue. Could you please assign it to me?
hi @VHemanth45 I think you can claim/work on individual files at a time. It's a big issue, so many people can take it up
@geetu040 can i work on this ??
sure anyone can work on this, just comment down which individual file you are working on and create a corresponding PR on it
Hi @geetu040 ,
Can I be assigned this issue to work on. I am currently working on the test_openml/test_api_calls.py
Hi @geetu040,
I’m currently working on the test_study/test_study_functions module for this issue.
Quick doubt — should we mock all calls that hit the test_server so the tests run fully offline, or are there any exceptions where live calls are still expected?
Thanks!
I'll take on test_tasks/test_task_functions.py
Hi, I would like to work on this issue. Could you please assign it to me?
I have started working on test_flows/test_flow.py
Hi @geetu040 . I have started working on test_utils/test_utils.py .
I'm working on tests/test_tasks/test_classification_task.py
i am working on tests/test_tasks/test_task_methods.py
pr link -PR
@geetu040 Hi !! i will be working on test_flows/test_flow_functions.py ,test_evaluations/test_evaluation_functions.py and test_setups/test_setup_functions.py
Hi @geetu040 everyone I am Shafwan, I am working on the /test_tasks/test_clustering_task.py
hi @geetu040 Im working on tests/test_datasets/test_dataset_functions.py — it has 58 @pytest.mark.test_server() markers so I am planning to split it across 2–3 PRs by logical test group rather than one large PR. Does that approach work or would you prefer a single PR?
hi @geetu040 Im working on
tests/test_datasets/test_dataset_functions.py— it has 58@pytest.mark.test_server()markers so I am planning to split it across 2–3 PRs by logical test group rather than one large PR. Does that approach work or would you prefer a single PR?
can you explain why would you need to split it?
Hi @geetu040, I would like to work on test_openml/test_api_calls.py
Hi @geetu040 i am working on tests/test_tasks/test_supervised_task.py
I'm working on test_datasets/test_dataset.py
hi @geetu040 Im working on
tests/test_datasets/test_dataset_functions.py— it has 58@pytest.mark.test_server()markers so I am planning to split it across 2–3 PRs by logical test group rather than one large PR. Does that approach work or would you prefer a single PR?can you explain why would you need to split it?
The 58 markers cover very different functionality (listing, downloading, caching, uploading, tagging, etc.) so splitting by logical group keeps each PR focused and easier to review. But if you'd prefer a single PR, I can do that too — happy to go either way.
Hi @geetu040 ! I am working on
test_runs/test_run_functions.py , test_tasks/test_regression_task.py