|
1 | 1 | # License: BSD 3-Clause |
2 | 2 | from __future__ import annotations |
3 | 3 |
|
| 4 | +from openml._api.config import settings |
4 | 5 | import pytest |
5 | 6 | import pandas as pd |
6 | | -import requests |
| 7 | +from openml._api.clients.http import HTTPClient |
7 | 8 | from openml.testing import TestBase |
8 | | -from openml._api import api_context |
9 | 9 | from openml._api.resources.tasks import TasksV1, TasksV2 |
10 | 10 | from openml.tasks.task import ( |
11 | 11 | OpenMLClassificationTask, |
|
17 | 17 | class TestTasksEndpoints(TestBase): |
18 | 18 | def setUp(self): |
19 | 19 | super().setUp() |
20 | | - self.v1_api = TasksV1(api_context.backend.tasks._http) |
21 | | - self.v2_api = TasksV2(api_context.backend.tasks._http) |
| 20 | + v1_http_client = HTTPClient( |
| 21 | + server=settings.api.v1.server, |
| 22 | + base_url=settings.api.v1.base_url, |
| 23 | + api_key=settings.api.v1.api_key, |
| 24 | + timeout=settings.api.v1.timeout, |
| 25 | + retries=settings.connection.retries, |
| 26 | + delay_method=settings.connection.delay_method, |
| 27 | + delay_time=settings.connection.delay_time, |
| 28 | + ) |
| 29 | + v2_http_client = HTTPClient( |
| 30 | + server=settings.api.v2.server, |
| 31 | + base_url=settings.api.v2.base_url, |
| 32 | + api_key=settings.api.v2.api_key, |
| 33 | + timeout=settings.api.v2.timeout, |
| 34 | + retries=settings.connection.retries, |
| 35 | + delay_method=settings.connection.delay_method, |
| 36 | + delay_time=settings.connection.delay_time, |
| 37 | + ) |
| 38 | + self.v1_api = TasksV1(v1_http_client) |
| 39 | + self.v2_api = TasksV2(v2_http_client) |
22 | 40 |
|
23 | 41 | def _get_first_tid(self, task_type: TaskType) -> int: |
24 | 42 | """Helper to find an existing task ID for a given type on the server.""" |
@@ -60,11 +78,8 @@ def test_v1_list_tasks(self): |
60 | 78 | def test_v2_get_task(self): |
61 | 79 | """Verify TasksV2 (JSON) skips gracefully if V2 is not supported.""" |
62 | 80 | tid = self._get_first_tid(TaskType.SUPERVISED_CLASSIFICATION) |
63 | | - try: |
64 | | - task_v2 = self.v2_api.get(tid) |
65 | | - assert int(task_v2.task_id) == tid |
66 | | - except (requests.exceptions.JSONDecodeError, Exception): |
67 | | - pytest.skip("V2 API JSON format not supported on this server.") |
| 81 | + task_v2 = self.v2_api.get(tid) |
| 82 | + assert int(task_v2.task_id) == tid |
68 | 83 |
|
69 | 84 | @pytest.mark.uses_test_server() |
70 | 85 | def test_v1_estimation_procedure_list(self): |
|
0 commit comments