From 309f7d18c7f03acb2f82a9df430f231bf591e5dd Mon Sep 17 00:00:00 2001 From: Vinicius Arcanjo Date: Wed, 12 Jan 2022 12:02:37 -0300 Subject: [PATCH 1/2] Fixed issue #128, GET /v2/evc/ 404 --- main.py | 2 +- tests/unit/test_main.py | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index 04e9358c..1b83f482 100644 --- a/main.py +++ b/main.py @@ -135,7 +135,7 @@ def get_circuit(self, circuit_id): except KeyError: result = f"circuit_id {circuit_id} not found" log.debug("get_circuit result %s %s", result, 404) - raise BadRequest(result) from KeyError + raise NotFound(result) from KeyError status = 200 log.debug("get_circuit result %s %s", result, status) return jsonify(result), status diff --git a/tests/unit/test_main.py b/tests/unit/test_main.py index 08cd109f..cdc32de9 100644 --- a/tests/unit/test_main.py +++ b/tests/unit/test_main.py @@ -1219,6 +1219,13 @@ def test_delete_schedule_not_found(self, mock_find_evc_by_sched): response = api.delete(url) self.assertEqual(response.status_code, 404) + def test_get_circuit_not_found(self): + """Test /v2/evc/ 404.""" + api = self.get_app_test_client(self.napp) + url = f'{self.server_name_url}/v2/evc/1234' + response = api.get(url) + self.assertEqual(response.status_code, 404) + @patch('requests.post') @patch('napps.kytos.mef_eline.scheduler.Scheduler.add') @patch('napps.kytos.mef_eline.storehouse.StoreHouse.save_evc') From c3b859ab8c39f60f88eebb62275f0e342e2e46a2 Mon Sep 17 00:00:00 2001 From: Vinicius Arcanjo Date: Wed, 12 Jan 2022 12:09:46 -0300 Subject: [PATCH 2/2] Fixed test test_get_specific_schedules_from_storehouse_not_found --- tests/unit/test_main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/test_main.py b/tests/unit/test_main.py index cdc32de9..9644b420 100644 --- a/tests/unit/test_main.py +++ b/tests/unit/test_main.py @@ -860,7 +860,7 @@ def test_get_specific_schedules_from_storehouse_not_found(self): expected = "circuit_id blah not found" # Assert response not found - self.assertEqual(response.status_code, 400, response.data) + self.assertEqual(response.status_code, 404, response.data) self.assertEqual(expected, json.loads(response.data)["description"]) def _uni_from_dict_side_effect(self, uni_dict):