Skip to content

test: Mock all production server calls in test_dataset_functions.py (#1649) - #1762

Open
sumitsaraswat362 wants to merge 3 commits into
openml:mainfrom
sumitsaraswat362:fix/mock-dataset-functions-live-tests
Open

sumitsaraswat362 wants to merge 3 commits into
openml:mainfrom
sumitsaraswat362:fix/mock-dataset-functions-live-tests

Conversation

@sumitsaraswat362

Copy link
Copy Markdown

Partially addresses #1649.

This PR removes all @pytest.mark.production_server() tests from test_dataset_functions.py by replacing them with mocked versions.

Changes (7 tests fixed)

Test Mock strategy
test_check_datasets_active mock.patch on list_datasets with fake DataFrame containing active/deactivated statuses
test__name_to_id_with_deactivated mock.patch on list_datasets
test__name_to_id_with_multiple_active mock.patch on list_datasets
test__name_to_id_with_version mock.patch on list_datasets
test__name_to_id_with_multiple_active_error mock.patch on list_datasets
test_get_dataset_cannot_access_private_data mock.patch on _perform_api_call raising OpenMLPrivateDatasetError
test_dataset_by_name_cannot_access_private_data Same mock; also removed @pytest.mark.skip since the mock makes it runnable
test_list_datasets_with_high_size_parameter mock.patch on _list_datasets

After this PR, test_dataset_functions.py has zero production_server markers remaining.

Sumit Saraswat added 3 commits October 3, 2026 18:58
Replaces the @pytest.mark.production_server() call in
test_list_clustering_task with a mocked requests.Session.request
using a saved XML response.

Partial fix for openml#1649.
Replace all three @pytest.mark.production_server() tests with mocked
versions that use saved XML responses:

- test_list_clustering_task: mock requests.Session.request with saved
  clustering task list XML
- test__get_task_live: mock _perform_api_call with saved task 34536 XML,
  also remove @unittest.skip since the mock makes it runnable
- test_get_task_different_types: mock _perform_api_call with saved XMLs
  for regression (5001), learning curve (64), and clustering (126033)

Mock XML files are placed in tests/files/mock_responses/tasks/ following
the existing project convention.

Partial fix for openml#1649.
Replace all seven @pytest.mark.production_server() tests with mocked
versions using unittest.mock.patch:

- test_check_datasets_active: mock list_datasets with fake DataFrame
- test__name_to_id_with_deactivated: mock list_datasets
- test__name_to_id_with_multiple_active: mock list_datasets
- test__name_to_id_with_version: mock list_datasets
- test__name_to_id_with_multiple_active_error: mock list_datasets
- test_get_dataset_cannot_access_private_data: mock _perform_api_call
  to raise OpenMLPrivateDatasetError
- test_dataset_by_name_cannot_access_private_data: same mock, also
  removed @pytest.mark.skip since the mock makes it runnable
- test_list_datasets_with_high_size_parameter: mock _list_datasets

After this PR, test_dataset_functions.py has zero production_server
markers remaining.

Partial fix for openml#1649.
Copilot AI balanced review requested due to automatic review settings October 3, 2026 15:10

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants