88
99from firebolt .common .settings import Settings
1010from firebolt .model .instance_type import InstanceType , InstanceTypeKey
11+ from firebolt .model .provider import Provider
1112from firebolt .model .region import Region , RegionKey
13+ from tests .util import list_to_paginated_response
1214
1315
1416@pytest .fixture
@@ -27,19 +29,34 @@ def access_token() -> str:
2729
2830
2931@pytest .fixture
30- def region_1 () -> Region :
32+ def provider () -> Provider :
33+ return Provider (
34+ provider_id = "mock_provider_id" ,
35+ name = "mock_provider_name" ,
36+ )
37+
38+
39+ @pytest .fixture
40+ def mock_providers (provider ) -> list [Provider ]:
41+ return [provider ]
42+
43+
44+ @pytest .fixture
45+ def region_1 (provider ) -> Region :
3146 return Region (
3247 key = RegionKey (
48+ provider_id = provider .provider_id ,
3349 region_id = "mock_region_id_1" ,
3450 ),
3551 name = "mock_region_1" ,
3652 )
3753
3854
3955@pytest .fixture
40- def region_2 () -> Region :
56+ def region_2 (provider ) -> Region :
4157 return Region (
4258 key = RegionKey (
59+ provider_id = provider .provider_id ,
4360 region_id = "mock_region_id_2" ,
4461 ),
4562 name = "mock_region_2" ,
@@ -52,9 +69,10 @@ def mock_regions(region_1, region_2) -> list[Region]:
5269
5370
5471@pytest .fixture
55- def instance_type_1 (region_1 ) -> InstanceType :
72+ def instance_type_1 (provider , region_1 ) -> InstanceType :
5673 return InstanceType (
5774 key = InstanceTypeKey (
75+ provider_id = provider .provider_id ,
5876 region_id = region_1 .key .region_id ,
5977 instance_type_id = "instance_type_id_1" ,
6078 ),
@@ -63,9 +81,10 @@ def instance_type_1(region_1) -> InstanceType:
6381
6482
6583@pytest .fixture
66- def instance_type_2 (region_2 ) -> InstanceType :
84+ def instance_type_2 (provider , region_2 ) -> InstanceType :
6785 return InstanceType (
6886 key = InstanceTypeKey (
87+ provider_id = provider .provider_id ,
6988 region_id = region_2 .key .region_id ,
7089 instance_type_id = "instance_type_id_2" ,
7190 ),
@@ -108,6 +127,26 @@ def auth_url(settings: Settings) -> str:
108127 return f"https://{ settings .server } /auth/v1/login"
109128
110129
130+ @pytest .fixture
131+ def provider_callback (provider_url : str , mock_providers ) -> Callable :
132+ def do_mock (
133+ request : httpx .Request = None ,
134+ ** kwargs ,
135+ ) -> Response :
136+ assert request .url == provider_url
137+ return to_response (
138+ status_code = httpx .codes .OK ,
139+ json = list_to_paginated_response (mock_providers ),
140+ )
141+
142+ return do_mock
143+
144+
145+ @pytest .fixture
146+ def provider_url (settings : Settings ) -> str :
147+ return f"https://{ settings .server } /compute/v1/providers"
148+
149+
111150@pytest .fixture
112151def db_name () -> str :
113152 return "database"
0 commit comments