26
26
27
27
28
28
@pytest .fixture
29
- async def setup_database (project_default ):
29
+ async def setup_database (project_default , server , client ):
30
+ id_env_1 = uuid .UUID ("11111111-1234-5678-1234-000000000001" )
31
+ result = await client .environment_create (
32
+ project_id = project_default ,
33
+ name = "test-env-b" ,
34
+ environment_id = id_env_1 ,
35
+ )
36
+ assert result .code == 200
37
+
38
+ id_env_2 = uuid .UUID ("11111111-1234-5678-1234-000000000002" )
39
+ result = await client .environment_create (
40
+ project_id = project_default ,
41
+ name = "test-env-c" ,
42
+ environment_id = id_env_2 ,
43
+ )
44
+ assert result .code == 200
45
+
46
+ id_env_3 = uuid .UUID ("11111111-1234-5678-1234-000000000003" )
47
+ result = await client .environment_create (
48
+ project_id = project_default ,
49
+ name = "test-env-a" ,
50
+ environment_id = id_env_3 ,
51
+ )
52
+ assert result .code == 200
53
+ result = await client .halt_environment (id_env_3 )
54
+ assert result .code == 200
55
+
30
56
def add_notifications (env_id : uuid .UUID ) -> list [models .Notification ]:
31
57
notifications = []
32
58
for i in range (8 ):
@@ -46,42 +72,9 @@ def add_notifications(env_id: uuid.UUID) -> list[models.Notification]:
46
72
)
47
73
return notifications
48
74
49
- # Initialize DB
75
+ # Add notifications
50
76
async with data .get_session () as session :
51
- environment_1 = models .Environment (
52
- id = uuid .UUID ("11111111-1234-5678-1234-000000000001" ),
53
- name = "test-env-b" ,
54
- project = project_default ,
55
- halted = False ,
56
- settings = {
57
- "enable_lsm_expert_mode" : False ,
58
- },
59
- )
60
- environment_2 = models .Environment (
61
- id = uuid .UUID ("11111111-1234-5678-1234-000000000002" ),
62
- name = "test-env-c" ,
63
- project = project_default ,
64
- halted = False ,
65
- settings = {
66
- "enable_lsm_expert_mode" : True ,
67
- },
68
- )
69
- environment_3 = models .Environment (
70
- id = uuid .UUID ("11111111-1234-5678-1234-000000000003" ),
71
- name = "test-env-a" ,
72
- project = project_default ,
73
- halted = True ,
74
- )
75
-
76
- session .add_all (
77
- [
78
- environment_1 ,
79
- environment_2 ,
80
- environment_3 ,
81
- * add_notifications (environment_1 .id ),
82
- * add_notifications (environment_2 .id ),
83
- ]
84
- )
77
+ session .add_all ([* add_notifications (id_env_1 ), * add_notifications (id_env_2 )])
85
78
await session .commit ()
86
79
await session .flush ()
87
80
@@ -95,62 +88,6 @@ async def test_graphql_schema(server, client):
95
88
assert result .result ["data" ]["__schema" ]
96
89
97
90
98
- async def test_query_is_expert_mode (server , client , setup_database , project_default ):
99
- """
100
- Tests the custom attribute isExpertMode
101
- """
102
- query = """
103
- {
104
- environments {
105
- edges {
106
- node {
107
- id
108
- halted
109
- isExpertMode
110
- project
111
- }
112
- }
113
- }
114
- }
115
- """
116
- result = await client .graphql (query = query )
117
- assert result .code == 200
118
- assert result .result ["data" ] == {
119
- "data" : {
120
- "environments" : {
121
- "edges" : [
122
- {
123
- "node" : {
124
- "halted" : False ,
125
- "id" : "11111111-1234-5678-1234-000000000001" ,
126
- "isExpertMode" : False ,
127
- "project" : project_default ,
128
- }
129
- },
130
- {
131
- "node" : {
132
- "halted" : False ,
133
- "id" : "11111111-1234-5678-1234-000000000002" ,
134
- "isExpertMode" : True ,
135
- "project" : project_default ,
136
- }
137
- },
138
- {
139
- "node" : {
140
- "halted" : True ,
141
- "id" : "11111111-1234-5678-1234-000000000003" ,
142
- "isExpertMode" : False ,
143
- "project" : project_default ,
144
- }
145
- },
146
- ]
147
- }
148
- },
149
- "errors" : None ,
150
- "extensions" : {},
151
- }
152
-
153
-
154
91
async def test_query_environments_with_filtering (server , client , setup_database ):
155
92
"""
156
93
Display basic filtering capabilities
@@ -178,7 +115,7 @@ async def test_query_environments_with_filtering(server, client, setup_database)
178
115
"node" : {
179
116
"halted" : False ,
180
117
"id" : "11111111-1234-5678-1234-000000000002" ,
181
- "isExpertMode" : True ,
118
+ "isExpertMode" : False ,
182
119
}
183
120
}
184
121
]
@@ -223,21 +160,19 @@ async def test_query_environments_with_paging(server, client, setup_database):
223
160
"""
224
161
Display basic paging capabilities
225
162
"""
226
- async with data .get_session () as session :
227
- project = models .Project (id = uuid .UUID ("00000000-1234-5678-1234-000000000002" ), name = "test-proj-2" )
228
- instances = [project ]
229
- for i in range (10 ):
230
- instances .append (
231
- models .Environment (
232
- id = uuid .UUID (f"21111111-1234-5678-1234-00000000000{ i } " ),
233
- name = f"test-env-{ i } " ,
234
- project = project .id ,
235
- halted = False ,
236
- )
237
- )
238
- session .add_all (instances )
239
- await session .commit ()
240
- await session .flush ()
163
+ # Create second project
164
+ id_project_2 = uuid .UUID ("00000000-1234-5678-1234-000000000002" )
165
+ result = await client .project_create (name = "test-proj-2" , project_id = id_project_2 )
166
+ assert result .code == 200
167
+ # Create environments in project
168
+ for i in range (10 ):
169
+ result = await client .environment_create (
170
+ project_id = id_project_2 ,
171
+ name = f"test-env-{ i } " ,
172
+ environment_id = uuid .UUID (f"21111111-1234-5678-1234-00000000000{ i } " ),
173
+ )
174
+ assert result .code == 200
175
+
241
176
query = """
242
177
{
243
178
environments(%s){
0 commit comments