Exemple #1
0
 def test_register_dict(self):
     """The registry shouldn't be cloned."""
     otp_admin = AdminSite(inherit_panels=False)
     self.assertDictEqual({}, otp_admin._registry)
"""

from django.conf.urls import url, include
from django.contrib import admin

from django_otp.admin import OTPAdmin, AdminSite

from .views import IndexView


class TestAdminSite(admin.AdminSite):
    """test admin site."""

    login_form = AdminSite.login_form
    login_template = AdminSite.login_template

    def __init__(self, *args, **kwargs):
        """Init."""
        super(TestAdminSite, self).__init__(*args, **kwargs)
        self._registry = admin.site._registry.copy()


OTPAdmin.enable()
admin.site = AdminSite()

urlpatterns = [
    url(r'^s/', admin.site.urls),
    url(r'^qr/', include("django_otp.urls")),
    url(r'^index/', IndexView.as_view())
]
Exemple #3
0
 def test_register_dict(self):
     """The registry should be cloned."""
     otp_admin = None
     with patch.dict(admin.site._registry, self.data, clear=True):
         otp_admin = AdminSite(inherit_panels=True)
     self.assertDictEqual(self.data, otp_admin._registry)