Skip to content
Snippets Groups Projects
Commit 67544728 authored by Erik Reid's avatar Erik Reid
Browse files

updated pop location tests to use abbreviations

parent 811b44a1
No related branches found
No related tags found
No related merge requests found
......@@ -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')
......
......@@ -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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment