Skip to content

Commit

Permalink
Merge pull request kytos#129 from kytos-ng/fix/issue_128
Browse files Browse the repository at this point in the history
[Fix] GET `/v2/evc/<circuit_id>` 404
  • Loading branch information
viniarck authored Jan 12, 2022
2 parents efdb3ab + 986e437 commit 63c1d9a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 8 additions & 1 deletion tests/unit/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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/<circuit_id> 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')
Expand Down

0 comments on commit 63c1d9a

Please sign in to comment.