from django.urls import path, reverse from django.test import RequestFactory from django.utils.translation import gettext_lazy as _ import pytest from aircox import admin_site, urls as _urls reqs = RequestFactory() _urls @pytest.fixture def site(): return admin_site.AdminSite() class TestAdminSite: @pytest.mark.django_db def test_each_context(self, site, staff_user): req = reqs.get("admin/test") req.user = staff_user context = site.each_context(req) assert "programs" in context assert "diffusions" in context assert "comments" in context def test_get_urls(self, site): extra_url = path("test/path", lambda *_, **kw: _) site.extra_urls.append(extra_url) urls = site.get_urls() assert extra_url in urls def test_get_tools(self, site): tools = site.get_tools() tools = dict(tools) assert tools == { _("Statistics"): reverse("admin:tools-stats"), } def test_route_view(self, site): # TODO pass