Skip to content
Snippets Groups Projects
Commit 482c001b authored by Nikolay Stanchev's avatar Nikolay Stanchev
Browse files

Refactored POST methods to PUT methods

parent ea556957
No related branches found
No related tags found
No related merge requests found
......@@ -42,10 +42,10 @@ def main(global_config, **settings):
config.add_route('aggregator_config', '/aggregator/config')
config.add_view(AggregatorConfig, attr='get', request_method='GET')
config.add_view(AggregatorConfig, attr='post', request_method='POST')
config.add_view(AggregatorConfig, attr='put', request_method='PUT')
config.add_route('aggregator_starter', '/aggregator/status')
config.add_view(aggregator_starter, request_method='POST')
config.add_route('aggregator_starter', '/aggregator/status', request_method='PUT')
config.add_view(aggregator_starter)
config.scan()
return config.make_wsgi_app()
......@@ -92,9 +92,9 @@ class TestAggregator(object):
("{}", None),
("{aggregator_running: true}", None),
])
def test_POST(self, input_body, output_value):
def test_PUT(self, input_body, output_value):
"""
Tests the POST method for the configuration of the aggregator
Tests the PUT method for the configuration of the aggregator
:param input_body: the input form parameter
:param output_value: the expected output value, None for expecting an Exception
"""
......@@ -111,15 +111,15 @@ class TestAggregator(object):
request.body = input_body.encode(request.charset)
if output_value is not None:
response = AggregatorConfig(request).post()
assert response == output_value, "Response of POST request must include the new status of the aggregator"
response = AggregatorConfig(request).put()
assert response == output_value, "Response of PUT request must include the new status of the aggregator"
for attribute in CONFIG_ATTRIBUTES:
assert self.config.get_settings().get(attribute) == output_value.get(attribute), "Aggregator settings configuration is not updated."
else:
error_raised = False
try:
AggregatorConfig(request).post()
AggregatorConfig(request).put()
except HTTPBadRequest:
error_raised = True
......
......@@ -91,11 +91,11 @@ class AggregatorConfig(object):
return config
def post(self):
def put(self):
"""
A POST API call for the status of the aggregator.
A PUT API call for the status of the aggregator.
:return: A JSON response to the POST call (success or fail).
:return: A JSON response to the PUT call (success or fail).
:raises HTTPBadRequest: if form argument cannot be converted to boolean
"""
......
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