From 767bc2663fecb1282ec44a9d912bb12960a224c2 Mon Sep 17 00:00:00 2001 From: Valentin Deniaud Date: Tue, 22 Dec 2020 17:44:06 +0100 Subject: [PATCH] misc: add authentic to statistics providers (#49700) --- combo/apps/dataviz/__init__.py | 3 +-- combo/settings.py | 5 ++--- tests/test_dataviz.py | 8 ++++++-- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/combo/apps/dataviz/__init__.py b/combo/apps/dataviz/__init__.py index 948f4960..44a02d38 100644 --- a/combo/apps/dataviz/__init__.py +++ b/combo/apps/dataviz/__init__.py @@ -39,9 +39,8 @@ class AppConfig(django.apps.AppConfig): if not settings.KNOWN_SERVICES: return - statistics_providers = settings.STATISTICS_PROVIDERS + ['bijoe'] start_update = timezone.now() - for provider in statistics_providers: + for provider in settings.STATISTICS_PROVIDERS: if isinstance(provider, dict): url = provider['url'] sites = {provider['id']: {'title': provider['name']}} diff --git a/combo/settings.py b/combo/settings.py index a9c702e2..b9bb78da 100644 --- a/combo/settings.py +++ b/combo/settings.py @@ -351,8 +351,8 @@ COMBO_MAP_LAYER_ASSET_SLOTS = {} # known services KNOWN_SERVICES = {} -# known services exposing statistics -STATISTICS_PROVIDERS = [] +# services known to expose statistics +STATISTICS_PROVIDERS = ['bijoe', 'authentic'] # PWA Settings PWA_VAPID_PUBLIK_KEY = None @@ -367,7 +367,6 @@ BOOKING_CALENDAR_CELL_ENABLED = False LEGACY_CHART_CELL_ENABLED = False NEWSLETTERS_CELL_ENABLED = False - def debug_show_toolbar(request): from debug_toolbar.middleware import show_toolbar as dt_show_toolbar return dt_show_toolbar(request) and not request.path.startswith('/__skeleton__/') diff --git a/tests/test_dataviz.py b/tests/test_dataviz.py index 66fda445..2342bc43 100644 --- a/tests/test_dataviz.py +++ b/tests/test_dataviz.py @@ -282,8 +282,6 @@ STATISTICS_LIST = { @remember_called def new_api_mock(url, request): - if url.path == '/visualization/json/': # nothing from bijoe - return {'content': b'{}', 'request': request, 'status_code': 200} if url.path == '/api/statistics/': return {'content': json.dumps(STATISTICS_LIST), 'request': request, 'status_code': 200} if url.path == '/api/statistics/one-serie/': @@ -322,6 +320,7 @@ def statistics(settings): "plop": {"title": "test", "url": "https://bijoe.example.com", "secret": "combo", "orig": "combo"} } } + settings.STATISTICS_PROVIDERS = ['bijoe'] appconfig = apps.get_app_config('dataviz') appconfig.hourly() assert Statistic.objects.count() == len(VISUALIZATION_JSON) @@ -1221,6 +1220,11 @@ def test_dataviz_api_list_statistics(new_api_statistics, settings): assert statistic.url == 'https://stat.com/stats/1/' assert statistic.available + settings.STATISTICS_PROVIDERS.append('unknown') + appconfig = apps.get_app_config('dataviz') + with HTTMock(url_mock): + appconfig.hourly() # unknown provider is ignored + @with_httmock(new_api_mock) def test_chartng_cell_new_api_filter_params(new_api_statistics, nocache, freezer): -- 2.20.1