diff --git a/inventory_provider/routes/neteng.py b/inventory_provider/routes/neteng.py index f171fa9d4d340f084817c46c1cc2619d78896d7b..dce7b2dc432e7caa6df58345441b14517603aa36 100644 --- a/inventory_provider/routes/neteng.py +++ b/inventory_provider/routes/neteng.py @@ -71,14 +71,14 @@ def get_location(equipment): value = r.get(f'ims:location:{equipment}') if not value: return Response( - response='no location information available for "{equipment}"', + response=f'no location information available for "{equipment}"', status=404, mimetype='text/html') value = json.loads(value.decode('utf-8')) if not value: return Response( - response='unexpected empty cached data for "{equipment}"', + response=f'unexpected empty cached data for "{equipment}"', status=500, mimetype='text/html') @@ -92,7 +92,7 @@ def get_pop_names(): Handler for `/neteng/pops` This method will return a list of defined pop - names. Elements from this list can be used + abbreviations. Elements from this list can be used with `/neteng/pop`. .. asjson:: @@ -111,14 +111,14 @@ def get_pop_names(): return jsonify(sorted(list(_pops()))) -@routes.route('/pop/<name>', methods=['GET', 'POST']) +@routes.route('/pop/<abbreviation>', methods=['GET', 'POST']) @common.require_accepts_json -def get_pop_location(name): +def get_pop_location(abbreviation): """ Handler for `/neteng/pop/<name>` This method will return location information for the POP - with name = `name` in IMS. + with abbreviation = `abbreviation` in IMS. 404 is returned if the POP name is not known. Otherwise the return value will be formatted as: @@ -131,17 +131,17 @@ def get_pop_location(name): r = common.get_current_redis() - value = r.get(f'ims:pop:{name}') + value = r.get(f'ims:pop:{abbreviation}') if not value: return Response( - response='no location information available for "{pop}"', + response=f'no location information available for "{abbreviation}"', status=404, mimetype='text/html') value = json.loads(value.decode('utf-8')) if not value: return Response( - response='unexpected empty cached data for "{name}"', + response=f'unexpected empty cached data for "{abbreviation}"', status=500, mimetype='text/html') diff --git a/test/test_neteng_routes.py b/test/test_neteng_routes.py index ceaa92c7735f6c9393563b0cc52d63db3a5ce5e9..7b23b5a2510650e0c8a96b6a9a74168926ad9396 100644 --- a/test/test_neteng_routes.py +++ b/test/test_neteng_routes.py @@ -40,7 +40,7 @@ def test_get_pops(client, mocked_redis): @pytest.mark.parametrize('pop_name', [ - 'AMSTERDAM', 'VIENNA', 'LONDON', 'LONDON 2' + 'AMS', 'LON', 'LON2', 'ORB', 'ORBE' ]) def test_pop_location(client, mocked_redis, pop_name): rv = client.post( @@ -56,6 +56,6 @@ def test_pop_location(client, mocked_redis, pop_name): def test_pop_not_found(client, mocked_redis): rv = client.post( - '/neteng/pop/BOGUS.POP.NAME', + '/neteng/pop/BOGUS.POP.ABBREV', headers={'Accept': ['application/json']}) assert rv.status_code == 404