Пример #1
0
    def test_original_django_sites_registry_remains_untouched(self):
        with fake_django_site_registry(self) as random_registry:
            from .support.models import TestCategory
            self.assertFalse(TestCategory in random_registry.keys())
            hatband.site.register(TestCategory)
            hatband.autodiscover()

            self.assertFalse(TestCategory in random_registry.keys())
Пример #2
0
    def test_has_a_copy_of_main_django_registry(self):
        random_registry = generate_random_registry()

        from django.contrib import admin
        site = fudge.Fake()
        site.has_attr(_registry=random_registry)

        with fake_autodiscover():
            with fudge.patched_context(admin, "site", site):
                hatband.autodiscover()
                for key in random_registry.keys():
                    self.assertTrue(key in hatband.site._registry)
Пример #3
0
    def test_has_hatband_registered_plus_(self):
        with fake_django_site_registry(self) as random_registry:
            from .support.models import TestCategory

            self.assertFalse(TestCategory in hatband.site._registry.keys(),
                    msg="Sanity check")
            hatband.site.register(TestCategory)
            self.assertTrue(TestCategory in hatband.site._registry.keys(),
                    msg="Sanity check")

            hatband.autodiscover()
            registry = hatband.site._registry.items()
            self.assertTrue(TestCategory in hatband.site._registry.keys(),
                    msg="TestCategory should still be in the registry")
Пример #4
0
from armstrong.core.arm_sections.views import SimpleSectionView, SectionFeed
from armstrong.core.arm_access.paywalls.subscription import SubscriptionPaywall
from armstrong.core.arm_access.paywalls import render_on_deny
from armstrong.apps.articles.models import Article
from armstrong.apps.articles.views import ArticleFeed
from django.views.generic.detail import DetailView
from django.views.generic import TemplateView
# ADMIN_BASE is the base URL for your Armstrong admin.  It is highly
# recommended that you change this to a different URL unless you enforce a
# strict password-strength policy for your users.
ADMIN_BASE = "admin"

# Comment the next two lines out to disable the admin:
from armstrong import hatband as admin

admin.autodiscover()

paywall = SubscriptionPaywall(
    permission_denied=render_on_deny('permission_denied.html'))

from .utils import get_url_for_model

urlpatterns = patterns(
    '',
    # Examples:
    # url(r'^$', 'baz.views.home', name='home'),
    # url(r'^baz/', include('baz.foo.urls')),

    # Comment the admin/doc line below to disable admin documentation:
    url(r'^%s/doc/' % ADMIN_BASE, include('django.contrib.admindocs.urls')),
Пример #5
0
try:
    from django.conf.urls import patterns, include, url
except ImportError:
    from django.conf.urls.defaults import patterns, include, url

from armstrong import hatband as admin
admin.autodiscover()

urlpatterns = patterns('',
	url(r'^admin/', include(admin.site.urls)),
)
Пример #6
0
    def test_dispatches_to_djangos_autodiscover(self):
        from django.contrib import admin
        autodiscover = fudge.Fake().is_callable().expects_call()

        with fudge.patched_context(admin, "autodiscover", autodiscover):
            hatband.autodiscover()
Пример #7
0
import json

from django.contrib.auth.models import User
from django.contrib.contenttypes.models import ContentType
from django.core.urlresolvers import reverse
from django.test.client import Client

from armstrong.hatband import autodiscover
from ._utils import HatbandTestCase
from .support.models import TestArticle, TestCategory

autodiscover()

PASSWORD = "******"

__all__ = [
    "GenericKeyFacetsViewTestCase",
    "TypeAndModelToQueryViewTestCase",
    "RenderModelPreviewTestCase",
    "ModelSearchBackfillMixinTestCase",
]


def staff_login(func):
    def inner(self, *args, **kwargs):
        self.client.login(username=self.staff.username, password=PASSWORD)
        return func(self, *args, **kwargs)
    return inner


def admin_login(func):