Esempio n. 1
0
    def test_get_page_for_apphook(self):

        with SettingsOverride(ROOT_URLCONF='cms.test_utils.project.second_urls_for_apphook_tests'):
            en_title, de_title = self.create_base_structure(APP_NAME, ['en', 'de'])
            with force_language("en"):
                path = reverse('sample-settings')
            request = self.get_request(path)
            request.LANGUAGE_CODE = 'en'

            attached_to_page = applications_page_check(request, path=path[1:])  # strip leading slash
            self.assertEqual(attached_to_page.pk, en_title.page.pk)

            response = self.client.get(path)
            self.assertEqual(response.status_code, 200)

            self.assertTemplateUsed(response, 'sampleapp/home.html')
            self.assertContains(response, en_title.title)
            with force_language("de"):
                path = reverse('sample-settings')
            request = self.get_request(path)
            request.LANGUAGE_CODE = 'de'
            attached_to_page = applications_page_check(request, path=path[1:])  # strip leading slash and language prefix
            self.assertEqual(attached_to_page.pk, de_title.page.pk)

            response = self.client.get(path)
            self.assertEqual(response.status_code, 200)
            self.assertTemplateUsed(response, 'sampleapp/home.html')
            self.assertContains(response, de_title.title)

            apphook_pool.clear()
Esempio n. 2
0
    def test_include_urlconf(self):
        with SettingsOverride(
                ROOT_URLCONF=
                'cms.test_utils.project.second_urls_for_apphook_tests'):
            self.create_base_structure(APP_NAME, 'en')

            path = reverse('extra_second')
            response = self.client.get(path)
            self.assertEquals(response.status_code, 200)
            self.assertTemplateUsed(response, 'sampleapp/extra.html')
            self.assertContains(response, "test included urlconf")

            path = reverse('extra_first')
            response = self.client.get(path)
            self.assertEquals(response.status_code, 200)
            self.assertTemplateUsed(response, 'sampleapp/extra.html')
            self.assertContains(response, "test urlconf")
            with force_language("de"):
                path = reverse('extra_first')
            response = self.client.get(path)
            self.assertEquals(response.status_code, 200)
            self.assertTemplateUsed(response, 'sampleapp/extra.html')
            self.assertContains(response, "test urlconf")
            with force_language("de"):
                path = reverse('extra_second')
            response = self.client.get(path)
            self.assertEquals(response.status_code, 200)
            self.assertTemplateUsed(response, 'sampleapp/extra.html')
            self.assertContains(response, "test included urlconf")

            apphook_pool.clear()
Esempio n. 3
0
    def test_multiple_apphooks(self):
        # test for #1538
        apphook_pool.clear()
        superuser = get_user_model().objects.create_superuser(
            'admin', '*****@*****.**', 'admin')
        create_page(
            "home",
            "nav_playground.html",
            "en",
            created_by=superuser,
            published=True,
        )
        create_page("apphook1-page",
                    "nav_playground.html",
                    "en",
                    created_by=superuser,
                    published=True,
                    apphook="SampleApp")
        create_page("apphook2-page",
                    "nav_playground.html",
                    "en",
                    created_by=superuser,
                    published=True,
                    apphook="SampleApp2")

        reverse('sample-root')
        reverse('sample2-root')
        apphook_pool.clear()
Esempio n. 4
0
    def test_page_language_url_for_apphook(self):

        apphook_pool.clear()
        superuser = get_user_model().objects.create_superuser(
            'admin', '*****@*****.**', 'admin')
        page = create_page("home",
                           "nav_playground.html",
                           "en",
                           created_by=superuser)
        create_title('de', page.get_title(), page)
        page.publish('en')
        page.publish('de')

        child_page = create_page("child_page",
                                 "nav_playground.html",
                                 "en",
                                 created_by=superuser,
                                 parent=page)
        create_title('de', child_page.get_title(), child_page)
        child_page.publish('en')
        child_page.publish('de')

        child_child_page = create_page("child_child_page",
                                       "nav_playground.html",
                                       "en",
                                       created_by=superuser,
                                       parent=child_page,
                                       apphook='SampleApp')
        create_title("de", '%s_de' % child_child_page.get_title(),
                     child_child_page)
        child_child_page.publish('en')
        child_child_page.publish('de')

        # publisher_public is set to draft on publish, issue with one to one reverse
        child_child_page = self.reload(child_child_page)
        with force_language("en"):
            path = reverse('extra_first')

        request = self.get_request(path)
        request.LANGUAGE_CODE = 'en'
        request.current_page = child_child_page

        fake_context = {'request': request}
        tag = DumbPageLanguageUrl()

        output = tag.get_context(fake_context, 'en')
        url = output['content']

        self.assertEqual(url, '/en/child_page/child_child_page/extra_1/')

        output = tag.get_context(fake_context, 'de')
        url = output['content']
        # look the extra "_de"
        self.assertEqual(url, '/de/child_page/child_child_page_de/extra_1/')

        output = tag.get_context(fake_context, 'fr')
        url = output['content']
        self.assertEqual(url, '/fr/child_page/child_child_page/extra_1/')

        apphook_pool.clear()
Esempio n. 5
0
    def test_apphook_on_root(self):

        with SettingsOverride(
                ROOT_URLCONF='cms.test_utils.project.urls_for_apphook_tests'):
            apphook_pool.clear()
            superuser = User.objects.create_superuser('admin',
                                                      '*****@*****.**',
                                                      'admin')
            page = create_page("apphooked-page",
                               "nav_playground.html",
                               "en",
                               created_by=superuser,
                               published=True,
                               apphook="SampleApp")
            blank_page = create_page("not-apphooked-page",
                                     "nav_playground.html",
                                     "en",
                                     created_by=superuser,
                                     published=True,
                                     apphook="",
                                     slug='blankapp')
            english_title = page.title_set.all()[0]
            self.assertEquals(english_title.language, 'en')
            create_title("de", "aphooked-page-de", page, apphook="SampleApp")
            self.assertTrue(page.publish())
            self.assertTrue(blank_page.publish())
            with force_language("en"):
                response = self.client.get(self.get_pages_root())
            self.assertTemplateUsed(response, 'sampleapp/home.html')

            response = self.client.get('/en/blankapp/')
            self.assertTemplateUsed(response, 'nav_playground.html')

            apphook_pool.clear()
Esempio n. 6
0
    def test_apphook_on_root(self):

        with SettingsOverride(ROOT_URLCONF="cms.test_utils.project.urls_for_apphook_tests"):
            apphook_pool.clear()
            superuser = get_user_model().objects.create_superuser("admin", "*****@*****.**", "admin")
            page = create_page(
                "apphooked-page", "nav_playground.html", "en", created_by=superuser, published=True, apphook="SampleApp"
            )
            blank_page = create_page(
                "not-apphooked-page",
                "nav_playground.html",
                "en",
                created_by=superuser,
                published=True,
                apphook="",
                slug="blankapp",
            )
            english_title = page.title_set.all()[0]
            self.assertEqual(english_title.language, "en")
            create_title("de", "aphooked-page-de", page)
            self.assertTrue(page.publish("en"))
            self.assertTrue(page.publish("de"))
            self.assertTrue(blank_page.publish("en"))
            with force_language("en"):
                response = self.client.get(self.get_pages_root())
            self.assertTemplateUsed(response, "sampleapp/home.html")

            response = self.client.get("/en/blankapp/")
            self.assertTemplateUsed(response, "nav_playground.html")

            apphook_pool.clear()
Esempio n. 7
0
    def test_include_urlconf(self):
        with SettingsOverride(ROOT_URLCONF='cms.test_utils.project.second_urls_for_apphook_tests'):
            self.create_base_structure(APP_NAME, 'en')

            path = reverse('extra_second')
            response = self.client.get(path)
            self.assertEqual(response.status_code, 200)
            self.assertTemplateUsed(response, 'sampleapp/extra.html')
            self.assertContains(response, "test included urlconf")

            path = reverse('extra_first')
            response = self.client.get(path)
            self.assertEqual(response.status_code, 200)
            self.assertTemplateUsed(response, 'sampleapp/extra.html')
            self.assertContains(response, "test urlconf")
            with force_language("de"):
                path = reverse('extra_first')
            response = self.client.get(path)
            self.assertEqual(response.status_code, 200)
            self.assertTemplateUsed(response, 'sampleapp/extra.html')
            self.assertContains(response, "test urlconf")
            with force_language("de"):
                path = reverse('extra_second')
            response = self.client.get(path)
            self.assertEqual(response.status_code, 200)
            self.assertTemplateUsed(response, 'sampleapp/extra.html')
            self.assertContains(response, "test included urlconf")

            apphook_pool.clear()
Esempio n. 8
0
    def test_03_apphook_on_root(self):

        if APP_MODULE in sys.modules:
            del sys.modules[APP_MODULE]

        with SettingsOverride(ROOT_URLCONF='testapp.urls_for_apphook_tests'):
            apphook_pool.clear()
            superuser = User.objects.create_superuser('admin',
                                                      '*****@*****.**',
                                                      'admin')
            page = self.create_page(user=superuser, published=True)
            english_title = page.title_set.all()[0]
            self.assertEquals(english_title.language, 'en')
            Title.objects.create(
                language='de',
                title='%s DE' % english_title.title,
                slug=english_title.slug,
                path=english_title.path,
                page=page,
            )
            page.title_set.all().update(application_urls='SampleApp')
            self.assertTrue(page.publish())

            response = self.client.get(self.get_pages_root())
            self.assertTemplateUsed(response, 'sampleapp/home.html')
            apphook_pool.clear()
Esempio n. 9
0
    def tearDown(self):
        clear_app_resolvers()
        clear_url_caches()

        if APP_MODULE in sys.modules:
            del sys.modules[APP_MODULE]
        apphook_pool.clear()
    def _delete_modules(self):
        from cms.apphook_pool import apphook_pool

        delete = [
            "tests.sample_app_1",
            "tests.sample_app_1.cms_app",
            "tests.sample_app_1.cms_apps",
            "tests.sample_app_2",
            "tests.sample_app_2.cms_app",
            "tests.sample_app_2.cms_apps",
            "tests.sample_app_3",
            "tests.sample_app_3.cms_app",
            "tests.sample_app_3.cms_apps",
            "tests.sample_app_4",
            "tests.sample_app_4.cms_app",
            "tests.sample_app_4.cms_apps",
            "tests.sample_app_5",
            "tests.sample_app_5.cms_app",
            "tests.sample_app_5.cms_apps",
            "tests.sample_app_6",
            "tests.sample_app_6.cms_app",
            "tests.sample_app_6.cms_apps",
        ]
        for module in delete:
            if module in sys.modules:
                del sys.modules[module]
        if self.config:
            self.config.cmsapp = None
        apphook_pool.clear()
Esempio n. 11
0
    def create_base_structure(self, apphook, title_langs, namespace=None):
        apphook_pool.clear()
        superuser = get_user_model().objects.create_superuser('admin', '*****@*****.**', 'admin')
        self.superuser = superuser
        page = create_page("home", "nav_playground.html", "en",
                           created_by=superuser, published=True)
        create_title('de', page.get_title(), page)
        page.publish('de')
        child_page = create_page("child_page", "nav_playground.html", "en",
                                 created_by=superuser, published=True, parent=page)
        create_title('de', child_page.get_title(), child_page)
        child_page.publish('de')
        child_child_page = create_page("child_child_page", "nav_playground.html",
                                       "en", created_by=superuser, published=True, parent=child_page, apphook=apphook,
                                       apphook_namespace=namespace)
        create_title("de", child_child_page.get_title(), child_child_page)
        child_child_page.publish('de')
        # publisher_public is set to draft on publish, issue with onetoone reverse
        child_child_page = self.reload(child_child_page)

        if isinstance(title_langs, six.string_types):
            titles = child_child_page.publisher_public.get_title_obj(title_langs)
        else:
            titles = [child_child_page.publisher_public.get_title_obj(l) for l in title_langs]

        self.reload_urls()

        return titles
Esempio n. 12
0
    def apphook_clear(self):
        from cms.apphook_pool import apphook_pool

        for name, label in list(apphook_pool.get_apphooks()):
            if apphook_pool.apps[name].__class__.__module__ in sys.modules:
                del sys.modules[apphook_pool.apps[name].__class__.__module__]
        apphook_pool.clear()
Esempio n. 13
0
    def create_base_structure(self, apphook, title_langs, namespace=None):
        apphook_pool.clear()
        superuser = get_user_model().objects.create_superuser('admin', '*****@*****.**', 'admin')
        self.superuser = superuser
        page = create_page("home", "nav_playground.html", "en",
                           created_by=superuser, published=True)
        create_title('de', page.get_title(), page)
        page.publish('de')
        child_page = create_page("child_page", "nav_playground.html", "en",
                                 created_by=superuser, published=True, parent=page)
        create_title('de', child_page.get_title(), child_page)
        child_page.publish('de')
        child_child_page = create_page("child_child_page", "nav_playground.html",
                                       "en", created_by=superuser, published=True, parent=child_page, apphook=apphook,
                                       apphook_namespace=namespace)
        create_title("de", child_child_page.get_title(), child_child_page)
        child_child_page.publish('de')
        # publisher_public is set to draft on publish, issue with onetoone reverse
        child_child_page = self.reload(child_child_page)

        if isinstance(title_langs, six.string_types):
            titles = child_child_page.publisher_public.get_title_obj(title_langs)
        else:
            titles = [child_child_page.publisher_public.get_title_obj(l) for l in title_langs]

        self.reload_urls()

        return titles
Esempio n. 14
0
    def test_get_page_for_apphook(self):

        with SettingsOverride(ROOT_URLCONF='cms.test_utils.project.second_urls_for_apphook_tests'):
            en_title, de_title = self.create_base_structure(APP_NAME, ['en', 'de'])
            with force_language("en"):
                path = reverse('sample-settings')
            request = self.get_request(path)
            request.LANGUAGE_CODE = 'en'

            attached_to_page = applications_page_check(request, path=path[1:])  # strip leading slash
            self.assertEqual(attached_to_page.pk, en_title.page.pk)

            response = self.client.get(path)
            self.assertEqual(response.status_code, 200)

            self.assertTemplateUsed(response, 'sampleapp/home.html')
            self.assertContains(response, en_title.title)
            with force_language("de"):
                path = reverse('sample-settings')
            request = self.get_request(path)
            request.LANGUAGE_CODE = 'de'
            attached_to_page = applications_page_check(request, path=path[1:])  # strip leading slash and language prefix
            self.assertEqual(attached_to_page.pk, de_title.page.pk)

            response = self.client.get(path)
            self.assertEqual(response.status_code, 200)
            self.assertTemplateUsed(response, 'sampleapp/home.html')
            self.assertContains(response, de_title.title)

            apphook_pool.clear()
Esempio n. 15
0
    def tearDown(self):
        clear_app_resolvers()
        clear_url_caches()

        if APP_MODULE in sys.modules:
            del sys.modules[APP_MODULE]
        apphook_pool.clear()
Esempio n. 16
0
    def test_nested_apphooks_urls(self):
        # make sure that urlparams actually reach the apphook views
        with self.settings(ROOT_URLCONF='cms.test_utils.project.urls'):
            apphook_pool.clear()

            superuser = get_user_model().objects.create_superuser('admin', '*****@*****.**', 'admin')
            create_page("home", "nav_playground.html", "en", created_by=superuser, published=True, )
            parent_page = create_page("parent-apphook-page", "nav_playground.html", "en",
                                      created_by=superuser, published=True, apphook="ParentApp")
            create_page("child-apphook-page", "nav_playground.html", "en", parent=parent_page,
                        created_by=superuser, published=True, apphook="ChildApp")

            parent_app_path = reverse('parentapp_view', kwargs={'path': 'parent/path/'})
            child_app_path = reverse('childapp_view', kwargs={'path': 'child-path/'})

            # Ensure the page structure is ok before getting responses
            self.assertEqual(parent_app_path, '/en/parent-apphook-page/parent/path/')
            self.assertEqual(child_app_path, '/en/parent-apphook-page/child-apphook-page/child-path/')

            # Get responses for both paths and ensure that the right view will answer
            response = self.client.get(parent_app_path)
            self.assertContains(response, 'parent app content', status_code=200)

            response = self.client.get(child_app_path)
            self.assertContains(response, 'child app content', status_code=200)

            apphook_pool.clear()
Esempio n. 17
0
    def test_get_page_for_apphook(self):

        with SettingsOverride(ROOT_URLCONF="project.second_urls_for_apphook_tests"):

            apphook_pool.clear()
            superuser = User.objects.create_superuser("admin", "*****@*****.**", "admin")
            page = create_page("home", "nav_playground.html", "en", created_by=superuser, published=True)
            create_title("de", page.get_title(), page)
            child_page = create_page(
                "child_page", "nav_playground.html", "en", created_by=superuser, published=True, parent=page
            )
            create_title("de", child_page.get_title(), child_page)
            child_child_page = create_page(
                "child_child_page",
                "nav_playground.html",
                "en",
                created_by=superuser,
                published=True,
                parent=child_page,
                apphook="SampleApp",
            )
            create_title("de", child_child_page.get_title(), child_child_page, apphook="SampleApp")

            child_child_page.publish()
            # publisher_public is set to draft on publish, issue with onetoone reverse
            child_child_page = self.reload(child_child_page)

            en_title = child_child_page.publisher_public.get_title_obj("en")

            path = reverse("en:sample-settings")

            request = self.get_request(path)
            request.LANGUAGE_CODE = "en"

            attached_to_page = applications_page_check(request, path=path[1:])  # strip leading slash
            self.assertEquals(attached_to_page.pk, en_title.page.pk)

            response = self.client.get(path)
            self.assertEquals(response.status_code, 200)

            self.assertTemplateUsed(response, "sampleapp/home.html")
            self.assertContains(response, en_title.title)

            de_title = child_child_page.publisher_public.get_title_obj("de")
            path = reverse("de:sample-settings")

            request = self.get_request(path)
            request.LANGUAGE_CODE = "de"

            attached_to_page = applications_page_check(
                request, path=path[4:]
            )  # strip leading slash and language prefix
            self.assertEquals(attached_to_page.pk, de_title.page.pk)

            response = self.client.get(path)
            self.assertEquals(response.status_code, 200)
            self.assertTemplateUsed(response, "sampleapp/home.html")
            self.assertContains(response, de_title.title)

            apphook_pool.clear()
Esempio n. 18
0
    def test_include_urlconf(self):
        self.create_base_structure(APP_NAME, 'en')

        path = reverse('extra_second')
        response = self.client.get(path)
        self.assertEqual(response.status_code, 200)
        self.assertTemplateUsed(response, 'sampleapp/extra.html')
        self.assertContains(response, "test included urlconf")

        path = reverse('extra_first')
        response = self.client.get(path)
        self.assertEqual(response.status_code, 200)
        self.assertTemplateUsed(response, 'sampleapp/extra.html')
        self.assertContains(response, "test urlconf")
        with force_language("de"):
            path = reverse('extra_first')
        response = self.client.get(path)
        self.assertEqual(response.status_code, 200)
        self.assertTemplateUsed(response, 'sampleapp/extra.html')
        self.assertContains(response, "test urlconf")
        with force_language("de"):
            path = reverse('extra_second')
        response = self.client.get(path)
        self.assertEqual(response.status_code, 200)
        self.assertTemplateUsed(response, 'sampleapp/extra.html')
        self.assertContains(response, "test included urlconf")

        apphook_pool.clear()
Esempio n. 19
0
    def test_include_urlconf(self):
        self.create_base_structure(APP_NAME, 'en')

        path = reverse('extra_second')
        response = self.client.get(path)
        self.assertEqual(response.status_code, 200)
        self.assertTemplateUsed(response, 'sampleapp/extra.html')
        self.assertContains(response, "test included urlconf")

        path = reverse('extra_first')
        response = self.client.get(path)
        self.assertEqual(response.status_code, 200)
        self.assertTemplateUsed(response, 'sampleapp/extra.html')
        self.assertContains(response, "test urlconf")
        with force_language("de"):
            path = reverse('extra_first')
        response = self.client.get(path)
        self.assertEqual(response.status_code, 200)
        self.assertTemplateUsed(response, 'sampleapp/extra.html')
        self.assertContains(response, "test urlconf")
        with force_language("de"):
            path = reverse('extra_second')
        response = self.client.get(path)
        self.assertEqual(response.status_code, 200)
        self.assertTemplateUsed(response, 'sampleapp/extra.html')
        self.assertContains(response, "test included urlconf")

        apphook_pool.clear()
Esempio n. 20
0
    def test_apphook_on_root(self):
        apphook_pool.clear()
        superuser = get_user_model().objects.create_superuser(
            'admin', '*****@*****.**', 'admin')
        page = create_page("apphooked-page",
                           "nav_playground.html",
                           "en",
                           created_by=superuser,
                           published=True,
                           apphook="SampleApp")
        blank_page = create_page("not-apphooked-page",
                                 "nav_playground.html",
                                 "en",
                                 created_by=superuser,
                                 published=True,
                                 apphook="",
                                 slug='blankapp')
        english_title = page.title_set.all()[0]
        self.assertEqual(english_title.language, 'en')
        create_title("de", "aphooked-page-de", page)
        self.assertTrue(page.publish('en'))
        self.assertTrue(page.publish('de'))
        self.assertTrue(blank_page.publish('en'))
        with force_language("en"):
            response = self.client.get(self.get_pages_root())
        self.assertTemplateUsed(response, 'sampleapp/home.html')
        self.assertContains(response, '<--noplaceholder-->')
        response = self.client.get('/en/blankapp/')
        self.assertTemplateUsed(response, 'nav_playground.html')

        apphook_pool.clear()
Esempio n. 21
0
    def test_multiple_apphooks(self):
        # test for #1538
        with SettingsOverride(
                ROOT_URLCONF=
                'cms.test_utils.project.third_urls_for_apphook_tests'):
            apphook_pool.clear()
            superuser = User.objects.create_superuser('admin',
                                                      '*****@*****.**',
                                                      'admin')
            home_page = create_page(
                "home",
                "nav_playground.html",
                "en",
                created_by=superuser,
                published=True,
            )
            apphook1_page = create_page("apphook1-page",
                                        "nav_playground.html",
                                        "en",
                                        created_by=superuser,
                                        published=True,
                                        apphook="SampleApp")
            apphook2_page = create_page("apphook2-page",
                                        "nav_playground.html",
                                        "en",
                                        created_by=superuser,
                                        published=True,
                                        apphook="SampleApp2")

            reverse('sample-root')
            reverse('sample2-root')

            apphook_pool.clear()
Esempio n. 22
0
    def setUp(self):
        clear_app_resolvers()
        clear_url_caches()

        if APP_MODULE in sys.modules:
            del sys.modules[APP_MODULE]

        self.reload_urls()
        apphook_pool.clear()
Esempio n. 23
0
    def setUp(self):
        clear_app_resolvers()
        clear_url_caches()

        if APP_MODULE in sys.modules:
            del sys.modules[APP_MODULE]

        self.reload_urls()
        apphook_pool.clear()
Esempio n. 24
0
 def test_explicit_apphooks(self):
     """
     Test explicit apphook loading with the CMS_APPHOOKS setting.
     """
     apphook_pool.clear()
     hooks = apphook_pool.get_apphooks()
     app_names = [hook[0] for hook in hooks]
     self.assertEqual(len(hooks), 1)
     self.assertEqual(app_names, [APP_NAME])
     apphook_pool.clear()
Esempio n. 25
0
 def test_explicit_apphooks(self):
     """
     Test explicit apphook loading with the CMS_APPHOOKS setting.
     """
     apphook_pool.clear()
     hooks = apphook_pool.get_apphooks()
     app_names = [hook[0] for hook in hooks]
     self.assertEqual(len(hooks), 1)
     self.assertEqual(app_names, [APP_NAME])
     apphook_pool.clear()
Esempio n. 26
0
    def test_apphook_by_class(self):
        if APP_MODULE in sys.modules:
            del sys.modules[APP_MODULE]
        apphooks = ("%s.%s" % (APP_MODULE, APP_NAME),)

        with self.settings(CMS_APPHOOKS=apphooks):
            apphook_pool.clear()
            apphook = apphook_pool.get_apphook(APP_NAME)
            page = create_page(apphook=apphook, **self._get_default_create_page_arguments())
            self.assertEqual(page.get_application_urls("en"), APP_NAME)
Esempio n. 27
0
 def test_implicit_apphooks(self):
     """
     Test implicit apphook loading with INSTALLED_APPS cms_app.py
     """
     apphook_pool.clear()
     hooks = apphook_pool.get_apphooks()
     app_names = [hook[0] for hook in hooks]
     self.assertEqual(len(hooks), 6)
     self.assertIn(NS_APP_NAME, app_names)
     self.assertIn(APP_NAME, app_names)
     apphook_pool.clear()
Esempio n. 28
0
 def test_implicit_apphooks(self):
     """
     Test implicit apphook loading with INSTALLED_APPS cms_app.py
     """
     apphook_pool.clear()
     hooks = apphook_pool.get_apphooks()
     app_names = [hook[0] for hook in hooks]
     self.assertEqual(len(hooks), 6)
     self.assertIn(NS_APP_NAME, app_names)
     self.assertIn(APP_NAME, app_names)
     apphook_pool.clear()
Esempio n. 29
0
    def test_apphook_by_class(self):
        if APP_MODULE in sys.modules:
            del sys.modules[APP_MODULE]
        apphooks = ('%s.%s' % (APP_MODULE, APP_NAME), )

        with self.settings(CMS_APPHOOKS=apphooks):
            apphook_pool.clear()
            apphook = apphook_pool.get_apphook(APP_NAME)
            page = create_page(apphook=apphook,
                               **self._get_default_create_page_arguments())
            self.assertEqual(page.get_application_urls('en'), APP_NAME)
Esempio n. 30
0
 def test_explicit_apphooks(self):
     """
     Test explicit apphook loading with the CMS_APPHOOKS setting.
     """
     apphooks = ('%s.%s' % (APP_MODULE, APP_NAME), )
     with SettingsOverride(CMS_APPHOOKS=apphooks):
         apphook_pool.clear()
         hooks = apphook_pool.get_apphooks()
         app_names = [hook[0] for hook in hooks]
         self.assertEqual(len(hooks), 1)
         self.assertEqual(app_names, [APP_NAME])
         apphook_pool.clear()
Esempio n. 31
0
 def test_explicit_apphooks(self):
     """
     Test explicit apphook loading with the CMS_APPHOOKS setting.
     """
     apphooks = ("%s.%s" % (APP_MODULE, APP_NAME),)
     with SettingsOverride(CMS_APPHOOKS=apphooks):
         apphook_pool.clear()
         hooks = apphook_pool.get_apphooks()
         app_names = [hook[0] for hook in hooks]
         self.assertEqual(len(hooks), 1)
         self.assertEqual(app_names, [APP_NAME])
         apphook_pool.clear()
Esempio n. 32
0
    def test_page_language_url_for_apphook(self):

        apphook_pool.clear()
        superuser = get_user_model().objects.create_superuser("admin", "*****@*****.**", "admin")
        page = create_page("home", "nav_playground.html", "en", created_by=superuser)
        create_title("de", page.get_title(), page)
        page.publish("en")
        page.publish("de")

        child_page = create_page("child_page", "nav_playground.html", "en", created_by=superuser, parent=page)
        create_title("de", child_page.get_title(), child_page)
        child_page.publish("en")
        child_page.publish("de")

        child_child_page = create_page(
            "child_child_page",
            "nav_playground.html",
            "en",
            created_by=superuser,
            parent=child_page,
            apphook="SampleApp",
        )
        create_title("de", "%s_de" % child_child_page.get_title(), child_child_page)
        child_child_page.publish("en")
        child_child_page.publish("de")

        # publisher_public is set to draft on publish, issue with one to one reverse
        child_child_page = self.reload(child_child_page)
        with force_language("en"):
            path = reverse("extra_first")

        request = self.get_request(path)
        request.LANGUAGE_CODE = "en"
        request.current_page = child_child_page

        fake_context = {"request": request}
        tag = DumbPageLanguageUrl()

        output = tag.get_context(fake_context, "en")
        url = output["content"]

        self.assertEqual(url, "/en/child_page/child_child_page/extra_1/")

        output = tag.get_context(fake_context, "de")
        url = output["content"]
        # look the extra "_de"
        self.assertEqual(url, "/de/child_page/child_child_page_de/extra_1/")

        output = tag.get_context(fake_context, "fr")
        url = output["content"]
        self.assertEqual(url, "/fr/child_page/child_child_page/extra_1/")

        apphook_pool.clear()
Esempio n. 33
0
    def test_apphook_on_root_reverse(self):
        with SettingsOverride(ROOT_URLCONF='cms.test_utils.project.urls_for_apphook_tests'):
            apphook_pool.clear()
            superuser = User.objects.create_superuser('admin', '*****@*****.**', 'admin')
            page = create_page("apphooked-page", "nav_playground.html", "en",
                created_by=superuser, published=True, apphook="SampleApp")
            create_title("de", "aphooked-page-de", page, apphook="SampleApp")
            self.assertTrue(page.publish())

            self.assertFalse(reverse('sample-settings').startswith('//'))

            apphook_pool.clear()
Esempio n. 34
0
    def test_04_get_page_for_apphook(self):
        
        if APP_MODULE in sys.modules:
            del sys.modules[APP_MODULE]
            
        with SettingsOverride(ROOT_URLCONF='testapp.second_urls_for_apphook_tests'):
    
            apphook_pool.clear()    
            superuser = User.objects.create_superuser('admin', '*****@*****.**', 'admin')
            page = self.create_page(user=superuser, published=True)
            self.create_title(page.get_title(), page.get_slug(), 'de', page)
            child_page = self.create_page(page, user=superuser, published=True)
            self.create_title(child_page.get_title(), child_page.get_slug(), 'de', child_page)
            child_child_page = self.create_page(child_page, user=superuser, published=True)
            self.create_title(child_child_page.get_title(), child_child_page.get_slug(), 'de', child_child_page)
            child_child_page.title_set.all().update(application_urls='SampleApp')
            
            child_child_page.publish()
            # publisher_public is set to draft on publish, issue with onetoone reverse
            child_child_page = self.reload(child_child_page) 
            
            en_title = child_child_page.publisher_public.get_title_obj('en')

            path = reverse('en:sample-settings')
            
            request = self.get_request(path)
            request.LANGUAGE_CODE = 'en'
            
            attached_to_page = applications_page_check(request, path=path[1:]) # strip leading slash
            self.assertEquals(attached_to_page.pk, en_title.page.pk)            
            
            response = self.client.get(path)
            self.assertEquals(response.status_code, 200)

            self.assertTemplateUsed(response, 'sampleapp/home.html')
            self.assertContains(response, en_title.title)
            
            de_title = child_child_page.publisher_public.get_title_obj('de')
            path = reverse('de:sample-settings')
        
            request = self.get_request(path)
            request.LANGUAGE_CODE = 'de'
            
            attached_to_page = applications_page_check(request, path=path[4:]) # strip leading slash and language prefix
            self.assertEquals(attached_to_page.pk, de_title.page.pk)            
            
            response = self.client.get(path)
            self.assertEquals(response.status_code, 200)
            self.assertTemplateUsed(response, 'sampleapp/home.html')
            self.assertContains(response, de_title.title)
            
            apphook_pool.clear()
Esempio n. 35
0
def apphooks(*hooks):
    _apphooks = apphook_pool.apphooks
    _apps = apphook_pool.apps
    _discovered = apphook_pool.discovered
    apphook_pool.clear()
    for hook in hooks:
        apphook_pool.register(hook)
    try:
        yield
    finally:
        apphook_pool.apphooks = _apphooks
        apphook_pool.apps = _apps
        apphook_pool.discovered = _discovered
Esempio n. 36
0
    def test_apphook_on_root_reverse(self):
        apphook_pool.clear()
        superuser = get_user_model().objects.create_superuser('admin', '*****@*****.**', 'admin')
        page = create_page("apphooked-page", "nav_playground.html", "en",
                           created_by=superuser, published=True, apphook="SampleApp")
        create_title("de", "aphooked-page-de", page)
        self.assertTrue(page.publish('de'))
        self.assertTrue(page.publish('en'))

        self.reload_urls()

        self.assertFalse(reverse('sample-settings').startswith('//'))
        apphook_pool.clear()
Esempio n. 37
0
    def test_apphook_on_root_reverse(self):
        apphook_pool.clear()
        superuser = get_user_model().objects.create_superuser('admin', '*****@*****.**', 'admin')
        page = create_page("apphooked-page", "nav_playground.html", "en",
                           created_by=superuser, published=True, apphook="SampleApp")
        create_title("de", "aphooked-page-de", page)
        self.assertTrue(page.publish('de'))
        self.assertTrue(page.publish('en'))

        self.reload_urls()

        self.assertFalse(reverse('sample-settings').startswith('//'))
        apphook_pool.clear()
Esempio n. 38
0
    def test_multiple_apphooks(self):
        # test for #1538
        apphook_pool.clear()
        superuser = get_user_model().objects.create_superuser('admin', '*****@*****.**', 'admin')
        create_page("home", "nav_playground.html", "en", created_by=superuser, published=True, )
        create_page("apphook1-page", "nav_playground.html", "en",
                    created_by=superuser, published=True, apphook="SampleApp")
        create_page("apphook2-page", "nav_playground.html", "en",
                    created_by=superuser, published=True, apphook="SampleApp2")

        reverse('sample-root')
        reverse('sample2-root')
        apphook_pool.clear()
Esempio n. 39
0
 def test_implicit_apphooks(self):
     """
     Test implicit apphook loading with INSTALLED_APPS + cms_app.py
     """
         
     apps = ['cms.test_utils.project.sampleapp']
     with SettingsOverride(INSTALLED_APPS=apps, ROOT_URLCONF='cms.test_utils.project.urls_for_apphook_tests'):
         apphook_pool.clear()
         hooks = apphook_pool.get_apphooks()
         app_names = [hook[0] for hook in hooks]
         self.assertEqual(len(hooks), 1)
         self.assertEqual(app_names, [APP_NAME])
         apphook_pool.clear()
Esempio n. 40
0
 def test_implicit_apphooks(self):
     """
     Test implicit apphook loading with INSTALLED_APPS + cms_app.py
     """
         
     apps = ['cms.test_utils.project.sampleapp']
     with SettingsOverride(INSTALLED_APPS=apps, ROOT_URLCONF='cms.test_utils.project.urls_for_apphook_tests'):
         apphook_pool.clear()
         hooks = apphook_pool.get_apphooks()
         app_names = [hook[0] for hook in hooks]
         self.assertEqual(len(hooks), 1)
         self.assertEqual(app_names, [APP_NAME])
         apphook_pool.clear()
def apphooks(*hooks):
    _apphooks = apphook_pool.apphooks
    _apps = apphook_pool.apps
    _discovered = apphook_pool.discovered
    apphook_pool.clear()
    for hook in hooks:
        apphook_pool.register(hook)
    try:
        yield
    finally:
        apphook_pool.apphooks = _apphooks
        apphook_pool.apps = _apps
        apphook_pool.discovered = _discovered
Esempio n. 42
0
    def test_get_page_for_apphook(self):
            
        with SettingsOverride(ROOT_URLCONF='cms.test_utils.project.second_urls_for_apphook_tests'):
    
            apphook_pool.clear()    
            superuser = User.objects.create_superuser('admin', '*****@*****.**', 'admin')
            page = create_page("home", "nav_playground.html", "en",
                               created_by=superuser, published=True)
            create_title('de', page.get_title(), page)
            child_page = create_page("child_page", "nav_playground.html", "en",
                         created_by=superuser, published=True, parent=page)
            create_title('de', child_page.get_title(), child_page)
            child_child_page = create_page("child_child_page", "nav_playground.html",
                "en", created_by=superuser, published=True, parent=child_page, apphook='SampleApp')
            create_title("de", child_child_page.get_title(), child_child_page, apphook='SampleApp')
            
            child_child_page.publish()
            # publisher_public is set to draft on publish, issue with onetoone reverse
            child_child_page = self.reload(child_child_page) 
            
            en_title = child_child_page.publisher_public.get_title_obj('en')

            path = reverse('en:sample-settings')
            
            request = self.get_request(path)
            request.LANGUAGE_CODE = 'en'
            
            attached_to_page = applications_page_check(request, path=path[1:]) # strip leading slash
            self.assertEquals(attached_to_page.pk, en_title.page.pk)            
            
            response = self.client.get(path)
            self.assertEquals(response.status_code, 200)

            self.assertTemplateUsed(response, 'sampleapp/home.html')
            self.assertContains(response, en_title.title)
            
            de_title = child_child_page.publisher_public.get_title_obj('de')
            path = reverse('de:sample-settings')
        
            request = self.get_request(path)
            request.LANGUAGE_CODE = 'de'
            
            attached_to_page = applications_page_check(request, path=path[4:]) # strip leading slash and language prefix
            self.assertEquals(attached_to_page.pk, de_title.page.pk)            
            
            response = self.client.get(path)
            self.assertEquals(response.status_code, 200)
            self.assertTemplateUsed(response, 'sampleapp/home.html')
            self.assertContains(response, de_title.title)
            
            apphook_pool.clear()
Esempio n. 43
0
    def test_implicit_apphooks(self):
        """
        Test implicit apphook loading with INSTALLED_APPS cms_app.py
        """

        apps = ["cms.test_utils.project.sampleapp"]
        with SettingsOverride(INSTALLED_APPS=apps, ROOT_URLCONF="cms.test_utils.project.urls_for_apphook_tests"):
            apphook_pool.clear()
            hooks = apphook_pool.get_apphooks()
            app_names = [hook[0] for hook in hooks]
            self.assertEqual(len(hooks), 3)
            self.assertIn(NS_APP_NAME, app_names)
            self.assertIn(APP_NAME, app_names)
            apphook_pool.clear()
Esempio n. 44
0
    def setUp(self):
        super().setUp()
        from cms.apphook_pool import apphook_pool

        delete = [
            "djangocms_blog",
            "djangocms_blog.cms_app",
            "djangocms_blog.cms_apps",
        ]
        for module in delete:
            if module in sys.modules:
                del sys.modules[module]
        BlogConfig.cmsapp = None
        apphook_pool.clear()
Esempio n. 45
0
    def test_get_child_page_for_apphook_with_instance_namespace(self):
        en_title = self.create_base_structure(NS_APP_NAME, 'en', 'instance_ns')
        with force_language("en"):
            path = reverse('namespaced_app_ns:sample-settings')
            path_instance1 = reverse('instance_ns:sample-settings')
            path_instance2 = reverse('namespaced_app_ns:sample-settings', current_app='instance_ns')
        self.assertEqual(path, path_instance1)
        self.assertEqual(path, path_instance2)

        request = self.get_request(path)
        request.LANGUAGE_CODE = 'en'
        attached_to_page = applications_page_check(request, path=path[1:])  # strip leading slash
        self.assertEqual(attached_to_page.pk, en_title.page_id)
        apphook_pool.clear()
Esempio n. 46
0
    def test_default_language_changer_with_implicit_current_app(self):
        self.create_base_structure(NS_APP_NAME, ['en', 'de'], 'namespaced_app_ns')
        self.reload_urls()
        with force_language("en"):
            path = reverse('namespaced_app_ns:translated-url')
        request = self.get_request(path)
        request.LANGUAGE_CODE = 'en'

        url = DefaultLanguageChanger(request)('en')
        self.assertEqual(url, path)

        url = DefaultLanguageChanger(request)('de')
        self.assertEqual(url, '/de%s' % path[3:].replace('/page', '/Seite'))
        apphook_pool.clear()
Esempio n. 47
0
    def setUp(self):
        super(SetupTest, self).setUp()
        from cms.apphook_pool import apphook_pool

        delete = [
            'djangocms_blog',
            'djangocms_blog.cms_app',
            'djangocms_blog.cms_apps',
        ]
        for module in delete:
            if module in sys.modules:
                del sys.modules[module]
        BlogConfig.cmsapp = None
        apphook_pool.clear()
Esempio n. 48
0
 def test_apphook_not_hooked(self):
     """
     Test details view when apphook pool has apphooks, but they're not
     actually hooked
     """
     if APP_MODULE in sys.modules:
         del sys.modules[APP_MODULE]
     apphooks = ("%s.%s" % (APP_MODULE, APP_NAME),)
     create_page("page2", "nav_playground.html", "en", published=True)
     with SettingsOverride(CMS_APPHOOKS=apphooks):
         apphook_pool.clear()
         response = self.client.get("/")
         self.assertEqual(response.status_code, 200)
         apphook_pool.clear()
Esempio n. 49
0
    def test_nested_apphooks_urls(self):
        # make sure that urlparams actually reach the apphook views
        with self.settings(ROOT_URLCONF='cms.test_utils.project.urls'):
            apphook_pool.clear()

            superuser = get_user_model().objects.create_superuser(
                'admin', '*****@*****.**', 'admin')
            create_page(
                "home",
                "nav_playground.html",
                "en",
                created_by=superuser,
                published=True,
            )
            parent_page = create_page("parent-apphook-page",
                                      "nav_playground.html",
                                      "en",
                                      created_by=superuser,
                                      published=True,
                                      apphook="ParentApp")
            create_page("child-apphook-page",
                        "nav_playground.html",
                        "en",
                        parent=parent_page,
                        created_by=superuser,
                        published=True,
                        apphook="ChildApp")

            parent_app_path = reverse('parentapp_view',
                                      kwargs={'path': 'parent/path/'})
            child_app_path = reverse('childapp_view',
                                     kwargs={'path': 'child-path/'})

            # Ensure the page structure is ok before getting responses
            self.assertEqual(parent_app_path,
                             '/en/parent-apphook-page/parent/path/')
            self.assertEqual(
                child_app_path,
                '/en/parent-apphook-page/child-apphook-page/child-path/')

            # Get responses for both paths and ensure that the right view will answer
            response = self.client.get(parent_app_path)
            self.assertContains(response,
                                'parent app content',
                                status_code=200)

            response = self.client.get(child_app_path)
            self.assertContains(response, 'child app content', status_code=200)

            apphook_pool.clear()
Esempio n. 50
0
    def setUp(self):
        super(SetupTest, self).setUp()
        from cms.apphook_pool import apphook_pool

        delete = [
            'djangocms_blog',
            'djangocms_blog.cms_app',
            'djangocms_blog.cms_apps',
        ]
        for module in delete:
            if module in sys.modules:
                del sys.modules[module]
        BlogConfig.cmsapp = None
        apphook_pool.clear()
Esempio n. 51
0
 def test_apphook_not_hooked(self):
     """
     Test details view when apphook pool has apphooks, but they're not
     actually hooked
     """
     if APP_MODULE in sys.modules:
         del sys.modules[APP_MODULE]
     apphooks = ('%s.%s' % (APP_MODULE, APP_NAME), )
     create_page("page2", "nav_playground.html", "en", published=True)
     with SettingsOverride(CMS_APPHOOKS=apphooks):
         apphook_pool.clear()
         response = self.client.get('/en/')
         self.assertEqual(response.status_code, 200)
         apphook_pool.clear()
Esempio n. 52
0
    def test_get_child_page_for_apphook_with_instance_namespace(self):
        en_title = self.create_base_structure(NS_APP_NAME, 'en', 'instance_ns')
        with force_language("en"):
            path = reverse('namespaced_app_ns:sample-settings')
            path_instance1 = reverse('instance_ns:sample-settings')
            path_instance2 = reverse('namespaced_app_ns:sample-settings', current_app='instance_ns')
        self.assertEqual(path, path_instance1)
        self.assertEqual(path, path_instance2)

        request = self.get_request(path)
        request.LANGUAGE_CODE = 'en'
        attached_to_page = applications_page_check(request, path=path[1:])  # strip leading slash
        self.assertEqual(attached_to_page.pk, en_title.page_id)
        apphook_pool.clear()
Esempio n. 53
0
 def test_02_implicit_apphooks(self):
     """
     Test implicit apphook loading with INSTALLED_APPS + cms_app.py
     """
     if APP_MODULE in sys.modules:
         del sys.modules[APP_MODULE]
     apps = ['testapp.sampleapp']
     with SettingsOverride(INSTALLED_APPS=apps):
         apphook_pool.clear()
         hooks = apphook_pool.get_apphooks()
         app_names = [hook[0] for hook in hooks]
         self.assertEqual(len(hooks), 1)
         self.assertEqual(app_names, [APP_NAME])
         apphook_pool.clear()
Esempio n. 54
0
    def test_default_language_changer_with_implicit_current_app(self):
        self.create_base_structure(NS_APP_NAME, ['en', 'de'], 'namespaced_app_ns')
        self.reload_urls()
        with force_language("en"):
            path = reverse('namespaced_app_ns:translated-url')
        request = self.get_request(path)
        request.LANGUAGE_CODE = 'en'

        url = DefaultLanguageChanger(request)('en')
        self.assertEqual(url, path)

        url = DefaultLanguageChanger(request)('de')
        self.assertEqual(url, '/de%s' % path[3:].replace('/page', '/Seite'))
        apphook_pool.clear()
Esempio n. 55
0
    def test_apphook_on_root_reverse(self):
        with SettingsOverride(ROOT_URLCONF='cms.test_utils.project.urls_for_apphook_tests'):
            apphook_pool.clear()
            superuser = User.objects.create_superuser('admin', '*****@*****.**', 'admin')
            page = create_page("apphooked-page", "nav_playground.html", "en",
                created_by=superuser, published=True, apphook="SampleApp")
            create_title("de", "aphooked-page-de", page, apphook="SampleApp")
            self.assertTrue(page.publish())

            self.reload_urls()

            self.assertFalse(reverse('sample-settings').startswith('//'))

            apphook_pool.clear()
Esempio n. 56
0
    def test_page_language_url_for_apphook(self):

        apphook_pool.clear()
        superuser = get_user_model().objects.create_superuser('admin', '*****@*****.**', 'admin')
        page = create_page("home", "nav_playground.html", "en",
                           created_by=superuser)
        create_title('de', page.get_title(), page)
        page.publish('en')
        page.publish('de')

        child_page = create_page("child_page", "nav_playground.html", "en",
                                 created_by=superuser, parent=page)
        create_title('de', child_page.get_title(), child_page)
        child_page.publish('en')
        child_page.publish('de')

        child_child_page = create_page("child_child_page", "nav_playground.html",
                                       "en", created_by=superuser, parent=child_page, apphook='SampleApp')
        create_title("de", '%s_de' % child_child_page.get_title(), child_child_page)
        child_child_page.publish('en')
        child_child_page.publish('de')

        # publisher_public is set to draft on publish, issue with one to one reverse
        child_child_page = self.reload(child_child_page)
        with force_language("en"):
            path = reverse('extra_first')

        request = self.get_request(path)
        request.LANGUAGE_CODE = 'en'
        request.current_page = child_child_page

        fake_context = {'request': request}
        tag = DumbPageLanguageUrl()

        output = tag.get_context(fake_context, 'en')
        url = output['content']

        self.assertEqual(url, '/en/child_page/child_child_page/extra_1/')

        output = tag.get_context(fake_context, 'de')
        url = output['content']
        # look the extra "_de"
        self.assertEqual(url, '/de/child_page/child_child_page_de/extra_1/')

        output = tag.get_context(fake_context, 'fr')
        url = output['content']
        self.assertEqual(url, '/fr/child_page/child_child_page/extra_1/')

        apphook_pool.clear()
Esempio n. 57
0
    def test_multiple_apphooks(self):
        # test for #1538
        with SettingsOverride(ROOT_URLCONF='cms.test_utils.project.third_urls_for_apphook_tests'):
            apphook_pool.clear()
            superuser = get_user_model().objects.create_superuser('admin', '*****@*****.**', 'admin')
            create_page("home", "nav_playground.html", "en", created_by=superuser, published=True, )
            create_page("apphook1-page", "nav_playground.html", "en",
                        created_by=superuser, published=True, apphook="SampleApp")
            create_page("apphook2-page", "nav_playground.html", "en",
                        created_by=superuser, published=True, apphook="SampleApp2")

            reverse('sample-root')
            reverse('sample2-root')

            apphook_pool.clear()
Esempio n. 58
0
    def test_get_sub_page_for_apphook_with_implicit_current_app(self):
        en_title = self.create_base_structure(NS_APP_NAME, 'en', 'namespaced_app_ns')
        with force_language("en"):
            path = reverse('namespaced_app_ns:current-app')
        request = self.get_request(path)
        request.LANGUAGE_CODE = 'en'

        attached_to_page = applications_page_check(request, path=path[1:])  # strip leading slash
        self.assertEqual(attached_to_page.pk, en_title.page.pk)

        response = self.client.get(path)
        self.assertEqual(response.status_code, 200)
        self.assertTemplateUsed(response, 'sampleapp/app.html')
        self.assertContains(response, 'namespaced_app_ns')
        self.assertContains(response, path)
        apphook_pool.clear()
Esempio n. 59
0
    def test_default_language_changer_with_implicit_current_app(self):
        with SettingsOverride(ROOT_URLCONF='cms.test_utils.project.second_urls_for_apphook_tests'):
            titles = self.create_base_structure(NS_APP_NAME, ['en', 'de'], 'namespaced_app_ns')  # nopyflakes
            self.reload_urls()
            with force_language("en"):
                path = reverse('namespaced_app_ns:translated-url')
            request = self.get_request(path)
            request.LANGUAGE_CODE = 'en'

            url = DefaultLanguageChanger(request)('en')
            self.assertEqual(url, path)

            url = DefaultLanguageChanger(request)('de')
            self.assertEqual(url, '/de%s' % path[3:].replace('/page', '/Seite'))

            apphook_pool.clear()
Esempio n. 60
0
    def test_02_implicit_apphooks(self):
        """
        Test implicit apphook loading with INSTALLED_APPS + cms_app.py
        """
        if APP_MODULE in sys.modules:
            del sys.modules[APP_MODULE]

        apps = ['testapp.sampleapp']
        with SettingsOverride(INSTALLED_APPS=apps,
                              ROOT_URLCONF='testapp.urls_for_apphook_tests'):
            apphook_pool.clear()
            hooks = apphook_pool.get_apphooks()
            app_names = [hook[0] for hook in hooks]
            self.assertEqual(len(hooks), 1)
            self.assertEqual(app_names, [APP_NAME])
            apphook_pool.clear()