Skip to content

Commit

Permalink
Change POST and DELETE return codes (kytos#22)
Browse files Browse the repository at this point in the history
* Change POST and DELETE return codes

POST and DELETE methods were returning 200 but
should return 202 when the NApp sucessfully send
the flows to the switches.
Fixes kytos#20 and kytos#21.

* Modify tests to reflect the different return codes
  • Loading branch information
Antonio Francisco authored Jul 16, 2021
1 parent 2c93280 commit b606f65
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ def _send_flow_mods_from_request(self, dpid, command, flows_dict=None):
self._install_flows(command, flows_dict,
self._get_all_switches_enabled())

return jsonify({"response": "FlowMod Messages Sent"})
return jsonify({"response": "FlowMod Messages Sent"}), 202

def _install_flows(self, command, flows_dict, switches=[], save=True):
"""Execute all procedures to install flows in the switches.
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def test_rest_add_and_delete_without_dpid(self, mock_install_flows):
response_1 = api.post(url, json={'flows': [{"priority": 25}]})
response_2 = api.post(url)

self.assertEqual(response_1.status_code, 200)
self.assertEqual(response_1.status_code, 202)
self.assertEqual(response_2.status_code, 400)

self.assertEqual(mock_install_flows.call_count, 2)
Expand All @@ -125,9 +125,9 @@ def test_rest_add_and_delete_with_dpid(self, mock_install_flows):
response_1 = api.post(url_1, json=data)
response_2 = api.post(url_2, json=data)

self.assertEqual(response_1.status_code, 200)
self.assertEqual(response_1.status_code, 202)
if method == 'delete':
self.assertEqual(response_2.status_code, 200)
self.assertEqual(response_2.status_code, 202)

self.assertEqual(mock_install_flows.call_count, 3)

Expand Down

0 comments on commit b606f65

Please sign in to comment.