diff --git a/test/conftest.py b/test/conftest.py index 4750be4912d0d92617302ad03812e096fd8b4925..81a61e687660f713df69414c20a69004898483b9 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -47,11 +47,11 @@ def data_config(): "readOnly": False } }, - "ignored_folders": [] + "ignored_folders": ['fakefolder'] } -def _test_data(filename): +def get_test_data(filename): data_filename = os.path.join( os.path.dirname(__file__), 'data', diff --git a/test/data/gws-direct-data.json b/test/data/gws-direct-data.json new file mode 100644 index 0000000000000000000000000000000000000000..61320aa29c227eb1c4b36ad670bec59f24ab466f --- /dev/null +++ b/test/data/gws-direct-data.json @@ -0,0 +1,654 @@ +[ + { + "nren": "GRENA", + "isp": "Cogent", + "hostname": "mx1.vie.at.geant.net", + "tag": "a", + "counters": [ + { + "field": "traffic_in", + "oid": "1.3.6.1.2.1.31.1.1.1.6.1057", + "snmp": { + "community": "TEST_COMMUNITY_STRING" + } + }, + { + "field": "traffic_out", + "oid": "1.3.6.1.2.1.31.1.1.1.10.1057", + "snmp": { + "community": "TEST_COMMUNITY_STRING" + } + } + ], + "info": "xe-4/2/3 - mx1.vie.at" + }, + { + "nren": "ARNES", + "isp": "Cogent", + "hostname": "88.200.0.63", + "tag": "a", + "counters": [ + { + "field": "discards_in", + "oid": "1.3.6.1.2.1.2.2.1.13.533", + "snmp": { + "community": "TEST_COMMUNITY_STRING" + } + }, + { + "field": "discards_out", + "oid": "1.3.6.1.2.1.2.2.1.19.533", + "snmp": { + "community": "TEST_COMMUNITY_STRING" + } + }, + { + "field": "errors_in", + "oid": "1.3.6.1.2.1.2.2.1.14.533", + "snmp": { + "community": "TEST_COMMUNITY_STRING" + } + }, + { + "field": "errors_out", + "oid": "1.3.6.1.2.1.2.2.1.20.533", + "snmp": { + "community": "TEST_COMMUNITY_STRING" + } + } + ] + }, + { + "nren": "ARNES", + "isp": "Cogent", + "hostname": "88.200.0.63", + "tag": "d", + "counters": [ + { + "field": "traffic_in", + "oid": "1.3.6.1.2.1.31.1.1.1.6.559", + "snmp": { + "community": "TEST_COMMUNITY_STRING" + } + }, + { + "field": "traffic_out", + "oid": "1.3.6.1.2.1.31.1.1.1.10.559", + "snmp": { + "community": "TEST_COMMUNITY_STRING" + } + } + ], + "info": "et-0/1/6 - rarnes2" + }, + { + "nren": "ARNES", + "isp": "Cogent", + "hostname": "88.200.0.63", + "tag": "e", + "counters": [ + { + "field": "traffic_in", + "oid": "1.3.6.1.2.1.31.1.1.1.6.703", + "snmp": { + "community": "TEST_COMMUNITY_STRING" + } + }, + { + "field": "traffic_out", + "oid": "1.3.6.1.2.1.31.1.1.1.10.703", + "snmp": { + "community": "TEST_COMMUNITY_STRING" + } + } + ], + "info": "et-0/1/6.0 - rarnes2" + }, + { + "nren": "ARNES", + "isp": "CenturyLink", + "hostname": "rarnes1.arnes.si", + "tag": "a", + "counters": [ + { + "field": "traffic_in", + "oid": "1.3.6.1.2.1.31.1.1.1.6.597", + "snmp": { + "community": "TEST_COMMUNITY_STRING" + } + }, + { + "field": "traffic_out", + "oid": "1.3.6.1.2.1.31.1.1.1.10.597", + "snmp": { + "community": "TEST_COMMUNITY_STRING" + } + } + ], + "info": "xe-0/0/1:0.0 - rarnes1" + }, + { + "nren": "CARNET", + "isp": "Cogent", + "hostname": "62.40.124.10", + "tag": "a", + "counters": [ + { + "field": "traffic_in", + "oid": "1.3.6.1.2.1.31.1.1.1.6.35", + "snmp": { + "community": "TEST_COMMUNITY_STRING" + } + }, + { + "field": "traffic_out", + "oid": "1.3.6.1.2.1.31.1.1.1.10.35", + "snmp": { + "community": "TEST_COMMUNITY_STRING" + } + } + ] + }, + { + "nren": "CARNET", + "isp": "Telia", + "hostname": "62.40.125.150", + "tag": "a", + "counters": [ + { + "field": "traffic_in", + "oid": "1.3.6.1.2.1.31.1.1.1.6.48", + "snmp": { + "community": "TEST_COMMUNITY_STRING" + } + }, + { + "field": "traffic_out", + "oid": "1.3.6.1.2.1.31.1.1.1.10.48", + "snmp": { + "community": "TEST_COMMUNITY_STRING" + } + } + ] + }, + { + "nren": "CARNET", + "isp": "CenturyLink", + "hostname": "62.40.125.150", + "tag": "a", + "counters": [ + { + "field": "traffic_in", + "oid": "1.3.6.1.2.1.31.1.1.1.6.49", + "snmp": { + "community": "TEST_COMMUNITY_STRING" + } + }, + { + "field": "traffic_out", + "oid": "1.3.6.1.2.1.31.1.1.1.10.49", + "snmp": { + "community": "TEST_COMMUNITY_STRING" + } + } + ], + "info": "TenGigE0/0/1/0 -> Core_LUMEN" + }, + { + "nren": "KIFU", + "isp": "Telia", + "hostname": "195.111.97.108", + "tag": "b", + "counters": [ + { + "field": "traffic_in", + "oid": "1.3.6.1.2.1.31.1.1.1.6.199", + "snmp": { + "community": "TEST_COMMUNITY_STRING" + } + }, + { + "field": "traffic_out", + "oid": "1.3.6.1.2.1.31.1.1.1.10.199", + "snmp": { + "community": "TEST_COMMUNITY_STRING" + } + } + ], + "info": "TenGigE0/0/0/13 --> TELIA Commodity Transit interface" + }, + { + "nren": "KIFU", + "isp": "Cogent", + "hostname": "195.111.97.109", + "tag": "b", + "counters": [ + { + "field": "traffic_in", + "oid": "1.3.6.1.2.1.31.1.1.1.6.196", + "snmp": { + "community": "TEST_COMMUNITY_STRING" + } + }, + { + "field": "traffic_out", + "oid": "1.3.6.1.2.1.31.1.1.1.10.196", + "snmp": { + "community": "TEST_COMMUNITY_STRING" + } + } + ], + "info": "TenGigE0/0/0/21 --> COGENT Commodity Transit interface" + }, + { + "nren": "RedIRIS", + "isp": "Telia", + "hostname": "130.206.206.253", + "tag": "a", + "counters": [ + { + "field": "traffic_in", + "oid": "1.3.6.1.2.1.31.1.1.1.6.385", + "snmp": { + "community": "TEST_COMMUNITY_STRING" + } + }, + { + "field": "traffic_out", + "oid": "1.3.6.1.2.1.31.1.1.1.10.385", + "snmp": { + "community": "TEST_COMMUNITY_STRING" + } + } + ], + "info": "Eth-Trunk7 - Telia agregado 3x10GE" + }, + { + "nren": "RedIRIS", + "isp": "Telia", + "hostname": "130.206.206.253", + "tag": "c", + "counters": [ + { + "field": "traffic_in", + "oid": "1.3.6.1.2.1.31.1.1.1.6.258", + "snmp": { + "community": "TEST_COMMUNITY_STRING" + } + }, + { + "field": "traffic_out", + "oid": "1.3.6.1.2.1.31.1.1.1.10.258", + "snmp": { + "community": "TEST_COMMUNITY_STRING" + } + } + ], + "info": "25GE3/0/6(10G) - Telia link 1 - IC-356455" + }, + { + "nren": "RedIRIS", + "isp": "Telia", + "hostname": "130.206.206.253", + "tag": "d", + "counters": [ + { + "field": "traffic_in", + "oid": "1.3.6.1.2.1.31.1.1.1.6.259", + "snmp": { + "community": "TEST_COMMUNITY_STRING" + } + }, + { + "field": "traffic_out", + "oid": "1.3.6.1.2.1.31.1.1.1.10.259", + "snmp": { + "community": "TEST_COMMUNITY_STRING" + } + } + ], + "info": "25GE3/0/7(10G) - Telia link 2 - IC-356456" + }, + { + "nren": "RedIRIS", + "isp": "Telia", + "hostname": "130.206.206.253", + "tag": "e", + "counters": [ + { + "field": "traffic_in", + "oid": "1.3.6.1.2.1.31.1.1.1.6.260", + "snmp": { + "community": "TEST_COMMUNITY_STRING" + } + }, + { + "field": "traffic_out", + "oid": "1.3.6.1.2.1.31.1.1.1.10.260", + "snmp": { + "community": "TEST_COMMUNITY_STRING" + } + } + ], + "info": "25GE3/0/8(10G) - Telia link 3 - IC-356457" + }, + { + "nren": "RedIRIS", + "isp": "CenturyLink", + "hostname": "130.206.212.253", + "tag": "a", + "counters": [ + { + "field": "traffic_in", + "oid": "1.3.6.1.2.1.31.1.1.1.6.15", + "snmp": { + "community": "TEST_COMMUNITY_STRING" + } + }, + { + "field": "traffic_out", + "oid": "1.3.6.1.2.1.31.1.1.1.10.15", + "snmp": { + "community": "TEST_COMMUNITY_STRING" + } + } + ], + "info": "100GE2/0/8" + }, + { + "nren": "RedIRIS", + "isp": "Cogent", + "hostname": "130.206.212.253", + "tag": "a", + "counters": [ + { + "field": "traffic_in", + "oid": "1.3.6.1.2.1.31.1.1.1.6.263", + "snmp": { + "community": "TEST_COMMUNITY_STRING" + } + }, + { + "field": "traffic_out", + "oid": "1.3.6.1.2.1.31.1.1.1.10.263", + "snmp": { + "community": "TEST_COMMUNITY_STRING" + } + } + ], + "info": "Eth-Trunk0.349 - aggregate 3x10GE" + }, + { + "nren": "RedIRIS", + "isp": "Cogent", + "hostname": "130.206.206.253", + "tag": "b", + "counters": [ + { + "field": "traffic_in", + "oid": "1.3.6.1.2.1.31.1.1.1.6.13", + "snmp": { + "community": "TEST_COMMUNITY_STRING" + } + }, + { + "field": "traffic_out", + "oid": "1.3.6.1.2.1.31.1.1.1.10.13", + "snmp": { + "community": "TEST_COMMUNITY_STRING" + } + } + ], + "info": "100GE1/0/6" + }, + { + "nren": "RoEduNet", + "isp": "Cogent", + "hostname": "149.6.50.10", + "tag": "a", + "counters": [ + { + "field": "traffic_in", + "oid": "1.3.6.1.2.1.31.1.1.1.6.531", + "snmp": { + "community": "TEST_COMMUNITY_STRING" + } + }, + { + "field": "traffic_out", + "oid": "1.3.6.1.2.1.31.1.1.1.10.531", + "snmp": { + "community": "TEST_COMMUNITY_STRING" + } + } + ] + }, + { + "nren": "RoEduNet", + "isp": "CenturyLink", + "hostname": "212.162.45.194", + "tag": "a", + "counters": [ + { + "field": "traffic_in", + "oid": "1.3.6.1.2.1.31.1.1.1.6.9", + "snmp": { + "community": "TEST_COMMUNITY_STRING" + } + }, + { + "field": "traffic_out", + "oid": "1.3.6.1.2.1.31.1.1.1.10.9", + "snmp": { + "community": "TEST_COMMUNITY_STRING" + } + } + ] + }, + { + "nren": "EENet", + "isp": "Telia", + "hostname": "193.40.133.2", + "tag": "a", + "counters": [ + { + "field": "traffic_in", + "oid": "1.3.6.1.2.1.31.1.1.1.6.16", + "snmp": { + "community": "TEST_COMMUNITY_STRING" + } + }, + { + "field": "traffic_out", + "oid": "1.3.6.1.2.1.31.1.1.1.10.16", + "snmp": { + "community": "TEST_COMMUNITY_STRING" + } + } + ], + "info": "Bundle-Ether5.1299, Telia Carrier IP traffic interface" + }, + { + "nren": "PSNC", + "isp": "CenturyLink", + "hostname": "212.191.126.6", + "tag": "a", + "counters": [ + { + "field": "traffic_in", + "oid": "1.3.6.1.2.1.31.1.1.1.6.675", + "snmp": { + "community": "TEST_COMMUNITY_STRING" + } + }, + { + "field": "traffic_out", + "oid": "1.3.6.1.2.1.31.1.1.1.10.675", + "snmp": { + "community": "TEST_COMMUNITY_STRING" + } + } + ] + }, + { + "nren": "PSNC", + "isp": "CenturyLink", + "hostname": "212.191.126.7", + "tag": "b", + "counters": [ + { + "field": "traffic_in", + "oid": "1.3.6.1.2.1.31.1.1.1.6.677", + "snmp": { + "community": "TEST_COMMUNITY_STRING" + } + }, + { + "field": "traffic_out", + "oid": "1.3.6.1.2.1.31.1.1.1.10.677", + "snmp": { + "community": "TEST_COMMUNITY_STRING" + } + } + ] + }, + { + "nren": "FCCN", + "isp": "Cogent", + "hostname": "GT41.fccn.pt", + "tag": "a", + "counters": [ + { + "field": "traffic_in", + "oid": "1.3.6.1.2.1.31.1.1.1.6.118", + "snmp": { + "community": "TEST_COMMUNITY_STRING" + } + }, + { + "field": "traffic_out", + "oid": "1.3.6.1.2.1.31.1.1.1.10.118", + "snmp": { + "community": "TEST_COMMUNITY_STRING" + } + } + ], + "info": "Hu0/1/0/7" + }, + { + "nren": "HEANET", + "isp": "CenturyLink", + "hostname": "core2-cwt.nn.hea.net", + "tag": "a", + "counters": [ + { + "field": "traffic_in", + "oid": "1.3.6.1.2.1.31.1.1.1.6.645", + "snmp": { + "sec-name": "FAKE-SEC-NAME", + "auth": { + "protocol": "MD5", + "password": "FAKE_PASSWORD" + }, + "priv": { + "protocol": "DES", + "password": "FAKE_PASSWORD" + } + } + }, + { + "field": "traffic_out", + "oid": "1.3.6.1.2.1.31.1.1.1.10.645", + "snmp": { + "sec-name": "FAKE-SEC-NAME", + "auth": { + "protocol": "MD5", + "password": "FAKE_PASSWORD" + }, + "priv": { + "protocol": "DES", + "password": "FAKE_PASSWORD" + } + } + } + ] + }, + { + "nren": "HEANET", + "isp": "GTT", + "hostname": "core1-pw.nn.hea.net", + "tag": "a", + "counters": [ + { + "field": "traffic_in", + "oid": "1.3.6.1.2.1.31.1.1.1.6.789", + "snmp": { + "sec-name": "FAKE-SEC-NAME", + "auth": { + "protocol": "MD5", + "password": "FAKE_PASSWORD" + }, + "priv": { + "protocol": "DES", + "password": "FAKE_PASSWORD" + } + } + }, + { + "field": "traffic_out", + "oid": "1.3.6.1.2.1.31.1.1.1.10.789", + "snmp": { + "sec-name": "FAKE-SEC-NAME", + "auth": { + "protocol": "MD5", + "password": "FAKE_PASSWORD" + }, + "priv": { + "protocol": "DES", + "password": "FAKE_PASSWORD" + } + } + } + ], + "info": "et-3/1/0" + }, + { + "nren": "HEANET", + "isp": "Cogent", + "hostname": "core1-cwt.nn.hea.net", + "tag": "a", + "counters": [ + { + "field": "traffic_in", + "oid": "1.3.6.1.2.1.31.1.1.1.6.837", + "snmp": { + "sec-name": "FAKE-SEC-NAME", + "auth": { + "protocol": "MD5", + "password": "FAKE_PASSWORD" + }, + "priv": { + "protocol": "DES", + "password": "FAKE_PASSWORD" + } + } + }, + { + "field": "traffic_out", + "oid": "1.3.6.1.2.1.31.1.1.1.10.837", + "snmp": { + "sec-name": "FAKE-SEC-NAME", + "auth": { + "protocol": "MD5", + "password": "FAKE_PASSWORD" + }, + "priv": { + "protocol": "DES", + "password": "FAKE_PASSWORD" + } + } + } + ], + "info": "et-3/1/0" + } +] diff --git a/test/test_grafana_dashboard.py b/test/test_grafana_dashboard.py index 31991c1a0966811fa042cef5d760a1604844b2a3..effec7094269999bcc2aaaf18af3b76e43339a2f 100644 --- a/test/test_grafana_dashboard.py +++ b/test/test_grafana_dashboard.py @@ -1,5 +1,6 @@ - +import pytest import json +import requests import responses from brian_dashboard_manager.grafana import dashboard, provision from brian_dashboard_manager.grafana.utils.request import TokenRequest @@ -67,8 +68,8 @@ def test_delete_dashboards(data_config): f'api/dashboards/uid/{UID+1}', callback=lambda f: (400, {}, '')) - data = dashboard._delete_dashboard(request, UID + 1) - assert data is False + with pytest.raises(requests.HTTPError): + data = dashboard._delete_dashboard(request, UID + 1) @responses.activate @@ -86,10 +87,15 @@ def test_delete_dashboard(data_config): url=request.BASE_URL + f'api/dashboards/uid/{UID}', json={'message': 'deleted dashboard'}) + responses.add( + method=responses.GET, + url=request.BASE_URL + f'api/dashboards/uid/{UID}', + json={}) + responses.add( method=responses.GET, url=request.BASE_URL + 'api/search', - json=dash) + json=[dash]) deleted = dashboard.delete_dashboard(request, dash) assert deleted diff --git a/test/test_grafana_datasource.py b/test/test_grafana_datasource.py index a453962530eb8378e1d0b7cd438d2a01391de22e..fe939950629514c56ec85862ef3d0e7eda4ad8b1 100644 --- a/test/test_grafana_datasource.py +++ b/test/test_grafana_datasource.py @@ -37,26 +37,26 @@ def test_get_missing_datasource_definitions(data_config): def test_datasource_provisioned(): - val = datasource._datasource_provisioned({}, []) + val = datasource._datasource_exists({}, []) assert val - val = datasource._datasource_provisioned({'id': 1}, []) + val = datasource._datasource_exists({'id': 1}, []) assert val is False - val = datasource._datasource_provisioned({'id': 1, "name": 'testcase2'}, - [{'id': -1, 'name': 'testcase1'}, - {'id': 1, 'name': 'testcase1'}]) + val = datasource._datasource_exists({'id': 1, "name": 'testcase2'}, + [{'id': -1, 'name': 'testcase1'}, + {'id': 1, 'name': 'testcase1'}]) assert val is False - val = datasource._datasource_provisioned({'id': 1}, - [{'id': -1, 'name': 'testcase1'}, - {'id': 1, 'name': 'testcase2'}]) + val = datasource._datasource_exists({'id': 1}, + [{'id': -1, 'name': 'testcase1'}, + {'id': 1, 'name': 'testcase2'}]) assert val - val = datasource._datasource_provisioned({'id': 2, "name": 'testcase2'}, - [{'id': -1, 'name': 'testcase1'}, - {'id': 1, 'name': 'testcase1'}, - {'id': 2, 'name': 'testcase2'}]) + val = datasource._datasource_exists({'id': 2, "name": 'testcase2'}, + [{'id': -1, 'name': 'testcase1'}, + {'id': 1, 'name': 'testcase1'}, + {'id': 2, 'name': 'testcase2'}]) assert val @@ -107,11 +107,11 @@ def test_create_prod_datasource(data_config): callback=post_callback) data = provision.create_datasource( - request, BODY, datasources=data_config['datasources']) + request, BODY) datasource_type = data['datasource']['type'] datasource_config_url = data_config['datasources'][datasource_type]['url'] - assert data['datasource']['url'] == datasource_config_url + assert data['datasource']['url'] != datasource_config_url @responses.activate @@ -135,7 +135,7 @@ def test_create_prod_datasource_fails(data_config): callback=lambda f: (400, {}, '')) data = provision.create_datasource( - request, BODY, datasources=data_config['datasources']) + request, BODY) # if an error occured when provisioning a datasource, we log the response # but return None diff --git a/test/test_gws_direct.py b/test/test_gws_direct.py index cbbd2380cc47cdd9f07af637096191d6e08c5b79..5ff611024caa768619263c39cecc828d7eecb675 100644 --- a/test/test_gws_direct.py +++ b/test/test_gws_direct.py @@ -1,111 +1,10 @@ import responses +from conftest import get_test_data from brian_dashboard_manager.templating.gws import generate_gws from brian_dashboard_manager.inventory_provider.interfaces import \ get_gws_direct - -TEST_DATA = [ - { - "nren": "ARNES", - "isp": "Cogent", - "hostname": "88.200.0.63", - "tag": "a", - "counters": [ - { - "field": "discards_in", - "oid": "1.3.6.1.2.1.2.2.1.13.533", - "community": "gn2nocT3st" - }, - { - "field": "discards_out", - "oid": "1.3.6.1.2.1.2.2.1.19.533", - "community": "gn2nocT3st" - }, - { - "field": "errors_in", - "oid": "1.3.6.1.2.1.2.2.1.14.533", - "community": "gn2nocT3st" - }, - { - "field": "errors_out", - "oid": "1.3.6.1.2.1.2.2.1.20.533", - "community": "gn2nocT3st" - } - ] - }, - { - "nren": "ARNES", - "isp": "Cogent", - "hostname": "88.200.0.63", - "tag": "b", - "counters": [ - { - "field": "traffic_in", - "oid": "1.3.6.1.2.1.31.1.1.1.6.531", - "community": "gn2nocT3st" - }, - { - "field": "traffic_out", - "oid": "1.3.6.1.2.1.31.1.1.1.10.531", - "community": "gn2nocT3st" - } - ] - }, - { - "nren": "ARNES", - "isp": "Cogent", - "hostname": "88.200.0.63", - "tag": "c", - "counters": [ - { - "field": "traffic_in", - "oid": "1.3.6.1.2.1.31.1.1.1.6.525", - "community": "gn2nocT3st" - }, - { - "field": "traffic_out", - "oid": "1.3.6.1.2.1.31.1.1.1.10.525", - "community": "gn2nocT3st" - } - ] - }, - { - "nren": "ARNES", - "isp": "Cogent", - "hostname": "88.200.0.63", - "tag": "d", - "counters": [ - { - "field": "traffic_in", - "oid": "1.3.6.1.2.1.31.1.1.1.6.553", - "community": "gn2nocT3st" - }, - { - "field": "traffic_out", - "oid": "1.3.6.1.2.1.31.1.1.1.10.553", - "community": "gn2nocT3st" - } - ] - }, - { - "nren": "ARNES", - "isp": "Telia", - "hostname": "62.40.124.6", - "tag": "a", - "counters": [ - { - "field": "traffic_in", - "oid": "1.3.6.1.2.1.31.1.1.1.6.611", - "community": "gn2nocT3st" - }, - { - "field": "traffic_out", - "oid": "1.3.6.1.2.1.31.1.1.1.10.611", - "community": "gn2nocT3st" - } - ] - } -] +TEST_DATA = get_test_data('gws-direct-data.json') @responses.activate @@ -120,10 +19,10 @@ def test_gws(data_config, client): dashboards = list(generate_gws(gws_data, 'testdatasource')) - assert len(dashboards) == 2 + assert len(dashboards) == 4 assert dashboards[0]['title'] == 'GWS Direct - Cogent' - assert len(dashboards[0]['panels']) == 3 + assert len(dashboards[0]['panels']) == 10 - assert dashboards[1]['title'] == 'GWS Direct - Telia' - assert len(dashboards[1]['panels']) == 1 + assert dashboards[1]['title'] == 'GWS Direct - CenturyLink' + assert len(dashboards[1]['panels']) == 7 diff --git a/test/test_services.py b/test/test_services.py deleted file mode 100644 index 075803b9dcdaae861a8dc70818d7a6dd7ca2e4b3..0000000000000000000000000000000000000000 --- a/test/test_services.py +++ /dev/null @@ -1,19 +0,0 @@ -import responses -from brian_dashboard_manager.services.api import fetch_services -from brian_dashboard_manager.templating.services import create_service_panels -from conftest import _test_data - - -@responses.activate -def test_services(data_config, client): - - responses.add( - method=responses.GET, - url=f"{data_config['reporting_provider']}/scid/current", - json=_test_data('services.json')) - - services = fetch_services(data_config['reporting_provider']) - - dashboards = list(create_service_panels(services, 'testdatasource')) - - assert dashboards diff --git a/test/test_update.py b/test/test_update.py index f3f6b6f1b8d272a801f51a1c62e02837946bd70e..55df28bd65daa4c56e2ff9d4e1597db4fb79b1d1 100644 --- a/test/test_update.py +++ b/test/test_update.py @@ -3,7 +3,7 @@ import json from brian_dashboard_manager.grafana.provision import provision_folder, \ provision -from conftest import _test_data +from conftest import get_test_data TEST_INTERFACES = [ { @@ -625,7 +625,7 @@ def test_provision_folder(data_config, mocker): responses.add( method=responses.GET, url=f"{data_config['reporting_provider']}/scid/current", - json=_test_data('services.json')) + json=get_test_data('services.json')) # just return a generated folder _mocked_find_folder = mocker.patch( @@ -709,7 +709,7 @@ def test_provision(data_config, mocker, client): responses.add( method=responses.GET, url=f"{data_config['reporting_provider']}/scid/current", - json=_test_data('services.json')) + json=get_test_data('services.json')) responses.add( method=responses.GET, @@ -734,12 +734,8 @@ def test_provision(data_config, mocker, client): responses.add( method=responses.GET, url=f"http://{data_config['hostname']}/api/folders", - json=[]) - - responses.add( - method='get', - url=f"http://{data_config['hostname']}/api/folders", - json=[]) + json=[ + generate_folder({'uid': 'fakeuid', 'title': 'fakefolder'})]) def folder_post(request): data = json.loads(request.body) diff --git a/test/test_version.py b/test/test_version.py new file mode 100644 index 0000000000000000000000000000000000000000..96fb2f327c69e6a0b52ce08946aa1180458db82e --- /dev/null +++ b/test/test_version.py @@ -0,0 +1,16 @@ +import responses + + +@responses.activate +def test_version(client): + + version = client.get('/version/', + headers={'Accept': 'application/json'}).json + assert version + + +@responses.activate +def test_version_no_json_accept(client): + + version = client.get('/version/') + assert version.status_code == 406