22from __future__ import annotations
33
44import pytest
5+ from openml ._api .config import settings
56
6- from openml ._api .runtime . core import build_backend
7+ from openml ._api .resources . evaluations import EvaluationsV1 , EvaluationsV2
78from openml .evaluations import OpenMLEvaluation
8- from openml .testing import TestBase
9+ from openml .testing import TestAPIBase
10+ from openml ._api .resources .base .fallback import FallbackProxy
911
1012
11- class TestEvaluationsV1 (TestBase ):
13+ class TestEvaluationsV1 (TestAPIBase ):
1214 """Tests for V1 XML API implementation of evaluations."""
1315
1416 _multiprocess_can_split_ = True
1517
1618 def setUp (self ) -> None :
1719 super ().setUp ()
18- backend = build_backend ('v1' , strict = True )
19- self .api = backend .evaluations
20+ self .client = self ._get_http_client (
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+ retry_policy = settings .connection .retry_policy ,
27+ )
28+ self .resource = EvaluationsV1 (self .client )
2029
2130 @pytest .mark .uses_test_server ()
2231 def test_list (self ):
23- evaluations = self .api .list (
32+ evaluations = self .resource .list (
2433 function = "predictive_accuracy" ,
2534 limit = 10 ,
2635 offset = 0 ,
@@ -31,13 +40,43 @@ def test_list(self):
3140 assert all (isinstance (e , OpenMLEvaluation ) for e in evaluations )
3241
3342
34- class TestEvaluationsV2 (TestBase ):
43+ class TestEvaluationsV2 (TestAPIBase ):
3544 """Tests for V2 JSON API implementation of evaluations."""
3645
3746 _multiprocess_can_split_ = True
3847
3948 def setUp (self ) -> None :
4049 super ().setUp ()
41- backend = build_backend ('v2' , strict = True )
42- self .api = backend .evaluations
43-
50+ self .client = self ._get_http_client (
51+ server = settings .api .v2 .server ,
52+ base_url = settings .api .v2 .base_url ,
53+ api_key = settings .api .v2 .api_key ,
54+ timeout = settings .api .v2 .timeout ,
55+ retries = settings .connection .retries ,
56+ retry_policy = settings .connection .retry_policy ,
57+ )
58+ self .resource = EvaluationsV2 (self .client )
59+
60+
61+ class TestEvaluationsCombined (TestAPIBase ):
62+ def setUp (self ):
63+ super ().setUp ()
64+ self .v1_client = self ._get_http_client (
65+ server = settings .api .v1 .server ,
66+ base_url = settings .api .v1 .base_url ,
67+ api_key = settings .api .v1 .api_key ,
68+ timeout = settings .api .v1 .timeout ,
69+ retries = settings .connection .retries ,
70+ retry_policy = settings .connection .retry_policy ,
71+ )
72+ self .v2_client = self ._get_http_client (
73+ server = settings .api .v2 .server ,
74+ base_url = settings .api .v2 .base_url ,
75+ api_key = settings .api .v2 .api_key ,
76+ timeout = settings .api .v2 .timeout ,
77+ retries = settings .connection .retries ,
78+ retry_policy = settings .connection .retry_policy ,
79+ )
80+ self .resource_v1 = EvaluationsV1 (self .v1_client )
81+ self .resource_v2 = EvaluationsV2 (self .v2_client )
82+ self .resource_fallback = FallbackProxy (self .resource_v2 , self .resource_v1 )
0 commit comments