Skip to content

Commit 0397614

Browse files
committed
some more tests
1 parent e40b405 commit 0397614

File tree

1 file changed

+61
-1
lines changed

1 file changed

+61
-1
lines changed

services/director/tests/test_handlers.py

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,30 @@ async def test_services_get(docker_registry, push_services):
8080
services = services_enveloped["data"]
8181
_check_services(created_services, services)
8282

83+
web_response = await rest.handlers.services_get(fake_request, "blahblah")
84+
assert web_response.status == 200
85+
assert web_response.content_type == "application/json"
86+
services_enveloped = json.loads(web_response.text)
87+
assert isinstance(services_enveloped["data"], list)
88+
services = services_enveloped["data"]
89+
assert len(services) == 0
90+
91+
web_response = await rest.handlers.services_get(fake_request, "computational")
92+
assert web_response.status == 200
93+
assert web_response.content_type == "application/json"
94+
services_enveloped = json.loads(web_response.text)
95+
assert isinstance(services_enveloped["data"], list)
96+
services = services_enveloped["data"]
97+
assert len(services) == 3
98+
99+
web_response = await rest.handlers.services_get(fake_request, "interactive")
100+
assert web_response.status == 200
101+
assert web_response.content_type == "application/json"
102+
services_enveloped = json.loads(web_response.text)
103+
assert isinstance(services_enveloped["data"], list)
104+
services = services_enveloped["data"]
105+
assert len(services) == 2
106+
83107
@pytest.mark.asyncio
84108
async def test_v0_services_conversion_to_new(configure_registry_access, push_v0_schema_services): #pylint: disable=W0613, W0621
85109
fake_request = "fake request"
@@ -132,8 +156,19 @@ async def test_v1_services_with_old_conversion(configure_registry_access, push_s
132156
@pytest.mark.asyncio
133157
async def test_services_by_key_version_get(configure_registry_access, push_services): #pylint: disable=W0613, W0621
134158
fake_request = "fake request"
159+
160+
with pytest.raises(web_exceptions.HTTPInternalServerError, message="Expecting internal server error"):
161+
web_response = await rest.handlers.services_by_key_version_get(fake_request, None, None)
162+
163+
with pytest.raises(web_exceptions.HTTPInternalServerError, message="Expecting internal server error"):
164+
web_response = await rest.handlers.services_by_key_version_get(fake_request, "whatever", None)
165+
166+
with pytest.raises(web_exceptions.HTTPNotFound, message="Expecting not found error"):
167+
web_response = await rest.handlers.services_by_key_version_get(fake_request, "whatever", "ofwhateverversion")
168+
135169
created_services = push_services(3,2)
136-
assert len(created_services) == 5
170+
assert len(created_services) == 5
171+
137172
retrieved_services = []
138173
for created_service in created_services:
139174
service_description = created_service["service_description"]
@@ -149,6 +184,31 @@ async def test_services_by_key_version_get(configure_registry_access, push_servi
149184

150185
async def _start_get_stop_services(push_services):
151186
fake_request = "fake request"
187+
188+
with pytest.raises(web_exceptions.HTTPInternalServerError, message="Expecting internal server error"):
189+
web_response = await rest.handlers.running_interactive_services_post(fake_request, None, None, None)
190+
191+
with pytest.raises(web_exceptions.HTTPInternalServerError, message="Expecting internal server error"):
192+
web_response = await rest.handlers.running_interactive_services_post(fake_request, "None", None, None)
193+
194+
with pytest.raises(web_exceptions.HTTPNotFound, message="Expecting not found error"):
195+
web_response = await rest.handlers.running_interactive_services_post(fake_request, "None", "None", None)
196+
197+
with pytest.raises(web_exceptions.HTTPNotFound, message="Expecting not found error"):
198+
web_response = await rest.handlers.running_interactive_services_post(fake_request, "None", "None", "ablah")
199+
200+
with pytest.raises(web_exceptions.HTTPInternalServerError, message="Expecting internal server error"):
201+
web_response = await rest.handlers.running_interactive_services_get(fake_request, None)
202+
203+
with pytest.raises(web_exceptions.HTTPNotFound, message="Expecting not found error"):
204+
web_response = await rest.handlers.running_interactive_services_get(fake_request, "service_uuid")
205+
206+
with pytest.raises(web_exceptions.HTTPInternalServerError, message="Expecting internal server error"):
207+
web_response = await rest.handlers.running_interactive_services_delete(fake_request, None)
208+
209+
with pytest.raises(web_exceptions.HTTPNotFound, message="Expecting not found error"):
210+
web_response = await rest.handlers.running_interactive_services_delete(fake_request, "service_uuid")
211+
152212
created_services = push_services(0,2)
153213
assert len(created_services) == 2
154214
for created_service in created_services:

0 commit comments

Comments
 (0)