Changeset View
Changeset View
Standalone View
Standalone View
swh/web/metrics/tests/test_app.py
# Copyright (C) 2022 The Software Heritage developers | # Copyright (C) 2022 The Software Heritage developers | ||||
# See the AUTHORS file at the top-level directory of this distribution | # See the AUTHORS file at the top-level directory of this distribution | ||||
# License: GNU Affero General Public License version 3, or any later version | # License: GNU Affero General Public License version 3, or any later version | ||||
# See top-level LICENSE file for more information | # See top-level LICENSE file for more information | ||||
import pytest | import pytest | ||||
from django.urls import get_resolver | from django.urls import get_resolver | ||||
from swh.web.metrics.urls import urlpatterns | from swh.web.metrics.urls import urlpatterns | ||||
@pytest.mark.django_db | @pytest.mark.django_db | ||||
def test_mailmap_deactivate(client, mailmap_admin, django_settings): | def test_metrics_deactivate(django_settings): | ||||
"""Check metrics feature is deactivated when the swh.web.metrics django | """Check metrics feature is deactivated when the swh.web.metrics django | ||||
application is not in installed apps.""" | application is not in installed apps.""" | ||||
django_settings.SWH_DJANGO_APPS = [ | django_settings.SWH_DJANGO_APPS = [ | ||||
app for app in django_settings.SWH_DJANGO_APPS if app != "swh.web.metrics" | app for app in django_settings.SWH_DJANGO_APPS if app != "swh.web.metrics" | ||||
] | ] | ||||
metrics_view_names = set(urlpattern.name for urlpattern in urlpatterns) | metrics_view_names = set(urlpattern.name for urlpattern in urlpatterns) | ||||
all_view_names = set(get_resolver().reverse_dict.keys()) | all_view_names = set(get_resolver().reverse_dict.keys()) | ||||
assert metrics_view_names & all_view_names == set() | assert metrics_view_names & all_view_names == set() |