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

basic sanity test case

parent 68440b99
No related branches found
No related tags found
No related merge requests found
......@@ -1278,8 +1278,7 @@ def get_service_types():
return Response(service_types, mimetype='application/json')
@routes.route("/gws/direct-config", methods=['GET', 'POST'])
@routes.route('/gws/direct-config', methods=['GET', 'POST'])
def gws_direct_config():
"""
Handler for `/poller/gws/direct-config` which returns
......@@ -1320,9 +1319,9 @@ def gws_direct_config():
elems = ['<tr>']
for name in _columns:
if header:
elems.append(f"<td>{counter['name']}</td>")
else:
elems.append(f'<th>{name}</th>')
else:
elems.append(f'<td>{counter[name]}</td>')
elems.append('</tr>')
return ''.join(elems)
......@@ -1343,7 +1342,7 @@ def gws_direct_config():
elems = ['<html>', '<body>', '<table>']
elems.append(_to_row(None, header=True))
elems += map(_to_row, _counters)
elems += map(_to_row, _counters())
elems += ['</table>', '</body>', '</html>']
return Response(
......
......@@ -4,7 +4,6 @@ import pytest
from inventory_provider.routes import poller
DEFAULT_REQUEST_HEADERS = {
# 'Content-type': 'application/json',
'Accept': ['application/json']
}
......@@ -315,3 +314,27 @@ def test_description_dashboard_parsing(interface, dashboard_info):
updated = poller._get_dashboard_data(interface)
info = updated['dashboard_info']
assert info == dashboard_info
def test_gws_config_json(client):
rv = client.get(
'/poller/gws/direct-config',
headers={'Accept': ['application/json']})
assert rv.status_code == 200
assert rv.is_json
response_data = json.loads(rv.data.decode('utf-8'))
# just a sanity check, no validation
# ... for now, this isn't an important interface
assert response_data
def test_gws_config_html(client):
rv = client.get(
'/poller/gws/direct-config?format=html',
headers={'Accept': ['text/html']})
assert rv.status_code == 200
response_data = rv.data.decode('utf-8')
# just a sanity check, no validation
# ... for now, this isn't an important interface
assert response_data.startswith('<html>')
assert response_data.endswith('</html>')
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment