66import pytest
77from aioresponses import aioresponses
88from faker import Faker
9- from hypothesis import HealthCheck , given , settings
10- from hypothesis import strategies as st
11- from models_library .api_schemas_webserver .clusters import (
12- ClusterCreate ,
13- ClusterPatch ,
14- ClusterPing ,
15- )
16- from models_library .clusters import ClusterID
179from models_library .projects import ProjectID
1810from models_library .projects_pipeline import ComputationTask
1911from models_library .projects_state import RunningState
@@ -38,11 +30,6 @@ def project_id(faker: Faker) -> ProjectID:
3830 return ProjectID (faker .uuid4 ())
3931
4032
41- @pytest .fixture
42- def cluster_id (faker : Faker ) -> ClusterID :
43- return ClusterID (faker .pyint (min_value = 0 ))
44-
45-
4633async def test_create_pipeline (
4734 mocked_director_v2 ,
4835 client ,
@@ -74,70 +61,3 @@ async def test_delete_pipeline(
7461 mocked_director_v2 , client , user_id : UserID , project_id : ProjectID
7562):
7663 await api .delete_pipeline (client .app , user_id , project_id )
77-
78-
79- @settings (suppress_health_check = [HealthCheck .function_scoped_fixture ])
80- @given (cluster_create = st .builds (ClusterCreate ))
81- async def test_create_cluster (
82- mocked_director_v2 , client , user_id : UserID , cluster_create
83- ):
84- created_cluster = await api .create_cluster (
85- client .app , user_id = user_id , new_cluster = cluster_create
86- )
87- assert created_cluster is not None
88- assert isinstance (created_cluster , dict )
89- assert "id" in created_cluster
90-
91-
92- async def test_list_clusters (mocked_director_v2 , client , user_id : UserID ):
93- list_of_clusters = await api .list_clusters (client .app , user_id = user_id )
94- assert isinstance (list_of_clusters , list )
95- assert len (list_of_clusters ) > 0
96-
97-
98- async def test_get_cluster (
99- mocked_director_v2 , client , user_id : UserID , cluster_id : ClusterID
100- ):
101- cluster = await api .get_cluster (client .app , user_id = user_id , cluster_id = cluster_id )
102- assert isinstance (cluster , dict )
103- assert cluster ["id" ] == cluster_id
104-
105-
106- async def test_get_cluster_details (
107- mocked_director_v2 , client , user_id : UserID , cluster_id : ClusterID
108- ):
109- cluster_details = await api .get_cluster_details (
110- client .app , user_id = user_id , cluster_id = cluster_id
111- )
112- assert isinstance (cluster_details , dict )
113-
114-
115- @settings (suppress_health_check = [HealthCheck .function_scoped_fixture ])
116- @given (cluster_patch = st .from_type (ClusterPatch ))
117- async def test_update_cluster (
118- mocked_director_v2 , client , user_id : UserID , cluster_id : ClusterID , cluster_patch
119- ):
120- print (f"--> updating cluster with { cluster_patch = } " )
121- updated_cluster = await api .update_cluster (
122- client .app , user_id = user_id , cluster_id = cluster_id , cluster_patch = cluster_patch
123- )
124- assert isinstance (updated_cluster , dict )
125- assert updated_cluster ["id" ] == cluster_id
126-
127-
128- async def test_delete_cluster (
129- mocked_director_v2 , client , user_id : UserID , cluster_id : ClusterID
130- ):
131- await api .delete_cluster (client .app , user_id = user_id , cluster_id = cluster_id )
132-
133-
134- @settings (suppress_health_check = [HealthCheck .function_scoped_fixture ])
135- @given (cluster_ping = st .builds (ClusterPing ))
136- async def test_ping_cluster (mocked_director_v2 , client , cluster_ping : ClusterPing ):
137- await api .ping_cluster (client .app , cluster_ping = cluster_ping )
138-
139-
140- async def test_ping_specific_cluster (
141- mocked_director_v2 , client , user_id : UserID , cluster_id : ClusterID
142- ):
143- await api .ping_specific_cluster (client .app , user_id = user_id , cluster_id = cluster_id )
0 commit comments