Skip to content
Snippets Groups Projects
Commit eb2126a5 authored by Nathan Hertz's avatar Nathan Hertz
Browse files

Updated tests to expect dictionaries in the response bodies instead of

JSON-formatted strings
parent 8738345d
No related branches found
No related tags found
1 merge request!96WS-31: Submit capability request view
This commit is part of merge request !96. Comments created here will be created in the context of that merge request.
...@@ -40,11 +40,13 @@ class MockCapabilityInfo(MagicMock): ...@@ -40,11 +40,13 @@ class MockCapabilityInfo(MagicMock):
name="null", name="null",
steps="test", steps="test",
max_jobs=2, max_jobs=2,
enabled=True,
), ),
Capability( Capability(
name="error", name="error",
steps="error", steps="error",
max_jobs=-1, max_jobs=-1,
enabled=True,
), ),
] ]
capability_requests = [ capability_requests = [
...@@ -137,6 +139,6 @@ def request_null_capability() -> DummyRequest: ...@@ -137,6 +139,6 @@ def request_null_capability() -> DummyRequest:
mock_capability_info = MockCapabilityInfo() mock_capability_info = MockCapabilityInfo()
request = DummyRequest( request = DummyRequest(
capability_info=mock_capability_info, capability_info=mock_capability_info,
capabilities=MockCapabilityService(mock_capability_info), capability_service=MockCapabilityService(mock_capability_info),
) )
return request return request
...@@ -23,9 +23,7 @@ def test_view_capability_request(test_config: Configurator, request_null_capabil ...@@ -23,9 +23,7 @@ def test_view_capability_request(test_config: Configurator, request_null_capabil
""" """
from capability.views.capability_request import view_capability_request from capability.views.capability_request import view_capability_request
expected_response = ( expected_response = {"capability_name": "null", "id": 0, "parameters": "-g", "state": "Created"}
'{"id": 0, "capability_name": "null", "state": "Created", "parameters": "-g"}'
)
request_null_capability.matchdict["capability_name"] = "null" request_null_capability.matchdict["capability_name"] = "null"
request_null_capability.matchdict["request_id"] = 0 request_null_capability.matchdict["request_id"] = 0
response = view_capability_request(request_null_capability) response = view_capability_request(request_null_capability)
...@@ -72,7 +70,7 @@ def test_create_capability_request( ...@@ -72,7 +70,7 @@ def test_create_capability_request(
response = create_capability_request(request_null_capability) response = create_capability_request(request_null_capability)
assert response.status_code == 200 assert response.status_code == 200
expected_response = '{"id": 1, "capability_name": "null", "state": "Ready", "parameters": "-g"}' expected_response = {"capability_name": "null", "id": 1, "parameters": "-g", "state": "Ready"}
assert response.json_body == expected_response assert response.json_body == expected_response
# Assert test capability has been added to list of capabilities (mocked) # Assert test capability has been added to list of capabilities (mocked)
assert request_null_capability.capability_info.lookup_capability_request(1) assert request_null_capability.capability_info.lookup_capability_request(1)
......
...@@ -23,7 +23,7 @@ def test_view_capability(test_config: Configurator, request_null_capability: Dum ...@@ -23,7 +23,7 @@ def test_view_capability(test_config: Configurator, request_null_capability: Dum
""" """
from capability.views.capability import view_capability from capability.views.capability import view_capability
expected_response = '{"name": "null", "max_jobs": 2, "steps": "test", "enabled": null}' expected_response = {"enabled": True, "max_jobs": 2, "name": "null", "steps": "test"}
request_null_capability.matchdict["capability_name"] = "null" request_null_capability.matchdict["capability_name"] = "null"
response = view_capability(request_null_capability) response = view_capability(request_null_capability)
assert response.status_code == 200 assert response.status_code == 200
...@@ -70,7 +70,7 @@ def test_create_capability(test_config: Configurator, request_null_capability: D ...@@ -70,7 +70,7 @@ def test_create_capability(test_config: Configurator, request_null_capability: D
response = create_capability(request_null_capability) response = create_capability(request_null_capability)
assert response.status_code == 200 assert response.status_code == 200
expected_response = '{"name": "test_create", "max_jobs": 1, "steps": "test", "enabled": true}' expected_response = {"enabled": True, "max_jobs": 1, "name": "test_create", "steps": "test"}
assert response.json_body == expected_response assert response.json_body == expected_response
# Assert test capability has been added to list of capabilities (mocked) # Assert test capability has been added to list of capabilities (mocked)
assert request_null_capability.capability_info.lookup_capability("test_create") assert request_null_capability.capability_info.lookup_capability("test_create")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment