9
9
10
10
API_VERSIONS = resources .listdir (resources .RESOURCE_OPENAPI_ROOT )
11
11
12
- @ pytest . mark . asyncio
12
+
13
13
async def test_root_get ():
14
14
fake_request = "fake request"
15
15
web_response = await rest .handlers .root_get (fake_request )
16
- assert web_response .content_type == "application/json"
16
+ assert web_response .content_type == "application/json"
17
17
assert web_response .status == 200
18
18
healthcheck_enveloped = json .loads (web_response .text )
19
19
assert "data" in healthcheck_enveloped
@@ -30,29 +30,29 @@ def _check_services(created_services, services, schema_version="v1"):
30
30
assert len (created_services ) == len (services )
31
31
32
32
created_service_descriptions = [x ["service_description" ] for x in created_services ]
33
-
33
+
34
34
json_schema_path = resources .get_path (resources .RESOURCE_NODE_SCHEMA )
35
35
assert json_schema_path .exists () == True
36
36
with json_schema_path .open () as file_pt :
37
37
service_schema = json .load (file_pt )
38
38
39
- for service in services :
39
+ for service in services :
40
40
if schema_version == "v1" :
41
41
assert created_service_descriptions .count (service ) == 1
42
42
json_schema_validator .validate_instance_object (service , service_schema )
43
43
44
- @ pytest . mark . asyncio
44
+
45
45
async def test_services_get (docker_registry , push_services ):
46
46
fake_request = "fake request"
47
47
# no registry defined
48
48
with pytest .raises (web_exceptions .HTTPInternalServerError , message = "Expecting HTTP Internal Error as no registry URL is defined" ):
49
49
services_enveloped = await rest .handlers .services_get (fake_request )
50
50
51
51
# wrong registry defined
52
- config .REGISTRY_URL = "blahblah"
52
+ config .REGISTRY_URL = "blahblah"
53
53
with pytest .raises (web_exceptions .HTTPInternalServerError , message = "Expecting HTTP Internal Error as SSL is enabled by default" ):
54
54
services_enveloped = await rest .handlers .services_get (fake_request )
55
-
55
+
56
56
# right registry defined
57
57
config .REGISTRY_URL = docker_registry
58
58
with pytest .raises (web_exceptions .HTTPInternalServerError , message = "Expecting HTTP Internal Error as SSL is enabled by default" ):
@@ -103,7 +103,7 @@ async def test_services_get(docker_registry, push_services):
103
103
services = services_enveloped ["data" ]
104
104
assert len (services ) == 2
105
105
106
- @ pytest . mark . asyncio
106
+
107
107
async def test_v0_services_conversion_to_new (configure_registry_access , push_v0_schema_services ): #pylint: disable=W0613, W0621
108
108
fake_request = "fake request"
109
109
created_services = push_v0_schema_services (3 ,2 )
@@ -117,7 +117,7 @@ async def test_v0_services_conversion_to_new(configure_registry_access, push_v0_
117
117
# ensure old style services are not retrieved
118
118
assert len (services ) == 0
119
119
120
- @ pytest . mark . asyncio
120
+
121
121
async def test_services_by_key_version_get (configure_registry_access , push_services ): #pylint: disable=W0613, W0621
122
122
fake_request = "fake request"
123
123
@@ -131,7 +131,7 @@ async def test_services_by_key_version_get(configure_registry_access, push_servi
131
131
web_response = await rest .handlers .services_by_key_version_get (fake_request , "whatever" , "ofwhateverversion" )
132
132
133
133
created_services = push_services (3 ,2 )
134
- assert len (created_services ) == 5
134
+ assert len (created_services ) == 5
135
135
136
136
retrieved_services = []
137
137
for created_service in created_services :
@@ -151,19 +151,19 @@ async def _start_get_stop_services(push_services, user_id):
151
151
152
152
with pytest .raises (web_exceptions .HTTPInternalServerError , message = "Expecting internal server error" ):
153
153
web_response = await rest .handlers .running_interactive_services_post (fake_request , None , None , None , None )
154
-
154
+
155
155
with pytest .raises (web_exceptions .HTTPInternalServerError , message = "Expecting internal server error" ):
156
156
web_response = await rest .handlers .running_interactive_services_post (fake_request , "None" , None , None , None )
157
157
158
158
with pytest .raises (web_exceptions .HTTPInternalServerError , message = "Expecting internal server error" ):
159
159
web_response = await rest .handlers .running_interactive_services_post (fake_request , "None" , "None" , None , None )
160
-
160
+
161
161
with pytest .raises (web_exceptions .HTTPNotFound , message = "Expecting not found error" ):
162
162
web_response = await rest .handlers .running_interactive_services_post (fake_request , "None" , "None" , "None" , None )
163
163
164
164
with pytest .raises (web_exceptions .HTTPNotFound , message = "Expecting not found error" ):
165
165
web_response = await rest .handlers .running_interactive_services_post (fake_request , "None" , "None" , "None" , "ablah" )
166
-
166
+
167
167
with pytest .raises (web_exceptions .HTTPInternalServerError , message = "Expecting internal server error" ):
168
168
web_response = await rest .handlers .running_interactive_services_get (fake_request , None )
169
169
@@ -201,11 +201,11 @@ async def _start_get_stop_services(push_services, user_id):
201
201
assert web_response .content_type == "application/json"
202
202
assert web_response .text is None
203
203
204
- @ pytest . mark . asyncio
204
+
205
205
async def test_running_services_post_and_delete_no_swarm (configure_registry_access , push_services , user_id ): #pylint: disable=W0613, W0621
206
206
with pytest .raises (web_exceptions .HTTPInternalServerError , message = "Expecting internal error as there is no docker swarm" ):
207
207
await _start_get_stop_services (push_services , user_id )
208
208
209
- @ pytest . mark . asyncio
209
+
210
210
async def test_running_services_post_and_delete (configure_registry_access , push_services , docker_swarm , user_id ): #pylint: disable=W0613, W0621
211
211
await _start_get_stop_services (push_services , user_id )
0 commit comments