0001-misc-add-authentic-to-statistics-providers-49700.patch
combo/apps/dataviz/__init__.py | ||
---|---|---|
39 | 39 |
if not settings.KNOWN_SERVICES: |
40 | 40 |
return |
41 | 41 | |
42 |
statistics_providers = settings.STATISTICS_PROVIDERS + ['bijoe'] |
|
43 | 42 |
start_update = timezone.now() |
44 |
for provider in statistics_providers:
|
|
43 |
for provider in settings.STATISTICS_PROVIDERS:
|
|
45 | 44 |
if isinstance(provider, dict): |
46 | 45 |
url = provider['url'] |
47 | 46 |
sites = {provider['id']: {'title': provider['name']}} |
combo/settings.py | ||
---|---|---|
351 | 351 |
# known services |
352 | 352 |
KNOWN_SERVICES = {} |
353 | 353 | |
354 |
# known services exposing statistics
|
|
355 |
STATISTICS_PROVIDERS = [] |
|
354 |
# services known to expose statistics
|
|
355 |
STATISTICS_PROVIDERS = ['bijoe', 'authentic']
|
|
356 | 356 | |
357 | 357 |
# PWA Settings |
358 | 358 |
PWA_VAPID_PUBLIK_KEY = None |
... | ... | |
367 | 367 |
LEGACY_CHART_CELL_ENABLED = False |
368 | 368 |
NEWSLETTERS_CELL_ENABLED = False |
369 | 369 | |
370 | ||
371 | 370 |
def debug_show_toolbar(request): |
372 | 371 |
from debug_toolbar.middleware import show_toolbar as dt_show_toolbar |
373 | 372 |
return dt_show_toolbar(request) and not request.path.startswith('/__skeleton__/') |
tests/test_dataviz.py | ||
---|---|---|
282 | 282 | |
283 | 283 |
@remember_called |
284 | 284 |
def new_api_mock(url, request): |
285 |
if url.path == '/visualization/json/': # nothing from bijoe |
|
286 |
return {'content': b'{}', 'request': request, 'status_code': 200} |
|
287 | 285 |
if url.path == '/api/statistics/': |
288 | 286 |
return {'content': json.dumps(STATISTICS_LIST), 'request': request, 'status_code': 200} |
289 | 287 |
if url.path == '/api/statistics/one-serie/': |
... | ... | |
322 | 320 |
"plop": {"title": "test", "url": "https://bijoe.example.com", "secret": "combo", "orig": "combo"} |
323 | 321 |
} |
324 | 322 |
} |
323 |
settings.STATISTICS_PROVIDERS = ['bijoe'] |
|
325 | 324 |
appconfig = apps.get_app_config('dataviz') |
326 | 325 |
appconfig.hourly() |
327 | 326 |
assert Statistic.objects.count() == len(VISUALIZATION_JSON) |
... | ... | |
1221 | 1220 |
assert statistic.url == 'https://stat.com/stats/1/' |
1222 | 1221 |
assert statistic.available |
1223 | 1222 | |
1223 |
settings.STATISTICS_PROVIDERS.append('unknown') |
|
1224 |
appconfig = apps.get_app_config('dataviz') |
|
1225 |
with HTTMock(url_mock): |
|
1226 |
appconfig.hourly() # unknown provider is ignored |
|
1227 | ||
1224 | 1228 | |
1225 | 1229 |
@with_httmock(new_api_mock) |
1226 | 1230 |
def test_chartng_cell_new_api_filter_params(new_api_statistics, nocache, freezer): |
1227 |
- |