From b606f6532bb613dfbbd934cd413cae504936d6da Mon Sep 17 00:00:00 2001 From: Antonio Francisco Date: Fri, 16 Jul 2021 10:58:41 -0300 Subject: [PATCH] Change POST and DELETE return codes (#22) * 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 #20 and #21. * Modify tests to reflect the different return codes --- main.py | 2 +- tests/unit/test_main.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/main.py b/main.py index fdf44bbf..f94aa200 100644 --- a/main.py +++ b/main.py @@ -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. diff --git a/tests/unit/test_main.py b/tests/unit/test_main.py index 8f409228..39d1872a 100644 --- a/tests/unit/test_main.py +++ b/tests/unit/test_main.py @@ -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) @@ -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)