import json import os import tempfile import pytest import brian_dashboard_manager @pytest.fixture def data_config(): return { "admin_username": "fakeadmin", "admin_password": "fakeadmin", "hostname": "myfakehostname.org", "inventory_provider": "inventory-provider01.geant.org:8080", "organizations": [ { "name": "Testorg1", "excluded_nrens": [], "excluded_dashboards": [] }, { "name": "GÉANT Testorg2", "excluded_nrens": [], "excluded_dashboards": [] }, { "name": "NRENsTestorg3", "excluded_nrens": [], "excluded_dashboards": [] }, { "name": "General Public", "excluded_nrens": ["JISC", "PSNC"], "excluded_dashboards": [] } ], "datasources": { "influxdb": { "name": "PollerInfluxDB", "type": "influxdb", "access": "proxy", "url": "http://prod-poller-ui01.geant.org:8086", "database": "poller", "basicAuth": False, "isDefault": True, "readOnly": False } } } @pytest.fixture def data_config_filename(data_config): with tempfile.NamedTemporaryFile() as f: f.write(json.dumps(data_config).encode('utf-8')) f.flush() yield f.name @pytest.fixture def client(data_config_filename): os.environ['CONFIG_FILENAME'] = data_config_filename with brian_dashboard_manager.create_app().test_client() as c: yield c