Example #1
0
    def test_urls_need_reloading_signal_change_slug(self):
        superuser = self.get_superuser()
        redirect_to = self.get_admin_url(Page, 'changelist')

        with apphooks(SampleApp):
            with self.login_user_context(superuser):
                with signal_tester(urls_need_reloading) as env:
                    self.assertEqual(env.call_count, 0)
                    page = create_page("apphooked-page",
                                       "nav_playground.html",
                                       "en",
                                       published=True,
                                       apphook="SampleApp",
                                       apphook_namespace="test")
                    # Change slug
                    endpoint = self.get_admin_url(Page, 'change', page.pk)
                    page_data = {
                        'title': 'apphooked-page',
                        'slug': 'apphooked-page-2',
                    }
                    response = self.client.post(endpoint, page_data)
                    self.assertRedirects(response, redirect_to)
                    # Publish should trigger the signal
                    endpoint = self.get_admin_url(Page, 'publish_page',
                                                  page.pk, 'en')
                    self.client.post(endpoint)
                    self.assertEqual(env.call_count, 1)
Example #2
0
    def test_urls_need_reloading_signal_set_apphook(self):
        superuser = self.get_superuser()

        with apphooks(SampleApp):
            with self.login_user_context(superuser):
                with signal_tester(urls_need_reloading) as env:
                    self.assertEqual(env.call_count, 0)
                    cms_page = create_page(
                        "apphooked-page",
                        "nav_playground.html",
                        "en",
                        published=True,
                    )
                    redirect_to = self.get_admin_url(Page, 'changelist')
                    endpoint = self.get_admin_url(Page, 'advanced',
                                                  cms_page.pk)
                    page_data = {
                        "redirect": "",
                        "language": "en",
                        "reverse_id": "",
                        "navigation_extenders": "",
                        "site": "1",
                        "xframe_options": "0",
                        "application_urls": "SampleApp",
                        "application_namespace": "sampleapp",
                        "overwrite_url": "",
                        "template": "INHERIT",
                    }
                    response = self.client.post(endpoint, page_data)
                    self.assertRedirects(response, redirect_to)
                    self.assertEqual(env.call_count, 1)
Example #3
0
 def test_uninstall_apphooks_without_apphook(self):
     with apphooks():
         out = io.StringIO()
         management.call_command(
             "cms",
             "uninstall",
             "apphooks",
             APPHOOK,
             interactive=False,
             stdout=out,
         )
         self.assertEqual(out.getvalue(), "no 'SampleApp' apphooks found\n")
Example #4
0
 def test_uninstall_apphooks_without_apphook(self):
     with apphooks():
         out = StringIO()
         management.call_command(
             "cms",
             "uninstall",
             "apphooks",
             APPHOOK,
             interactive=False,
             stdout=out,
         )
         self.assertEqual(out.getvalue(), "no 'SampleApp' apphooks found\n")
 def test_list_apphooks(self):
     with apphooks(SampleApp):
         out = StringIO()
         create_page('Hello Title', "nav_playground.html", "en", apphook=APPHOOK)
         self.assertEqual(Page.objects.filter(application_urls=APPHOOK).count(), 1)
         management.call_command(
             "cms",
             "list",
             "apphooks",
             interactive=False,
             stdout=out,
         )
         self.assertEqual(out.getvalue(), "SampleApp (draft)\n")
Example #6
0
 def test_urls_need_reloading_signal_create(self):
     with apphooks(SampleApp):
         with signal_tester(urls_need_reloading) as env:
             self.client.get('/')
             self.assertEqual(env.call_count, 0)
             create_page("apphooked-page",
                         "nav_playground.html",
                         "en",
                         published=True,
                         apphook="SampleApp",
                         apphook_namespace="test")
             self.client.get('/')
             self.assertEqual(env.call_count, 1)
Example #7
0
 def test_urls_need_reloading_signal_create(self):
     with apphooks(SampleApp):
         with signal_tester(urls_need_reloading) as env:
             self.client.get('/')
             self.assertEqual(env.call_count, 0)
             create_page(
                 "apphooked-page",
                 "nav_playground.html",
                 "en",
                 published=True,
                 apphook="SampleApp",
                 apphook_namespace="test"
             )
             self.client.get('/')
             self.assertEqual(env.call_count, 1)
Example #8
0
    def test_urls_need_reloading_signal_delete(self):
        superuser = self.get_superuser()

        with apphooks(SampleApp):
            with self.login_user_context(superuser):
                page = create_page("apphooked-page",
                                   "nav_playground.html",
                                   "en",
                                   published=True,
                                   apphook="SampleApp",
                                   apphook_namespace="test")

                with signal_tester(urls_need_reloading) as env:
                    endpoint = self.get_admin_url(Page, 'delete', page.pk)
                    self.assertEqual(env.call_count, 0)
                    self.client.post(endpoint, {'post': 'yes'})
                    self.assertEqual(env.call_count, 1)
Example #9
0
 def test_urls_need_reloading_signal_change_slug(self):
     with apphooks(SampleApp):
         with signal_tester(urls_need_reloading) as env:
             self.assertEqual(env.call_count, 0)
             page = create_page("apphooked-page",
                                "nav_playground.html",
                                "en",
                                published=True,
                                apphook="SampleApp",
                                apphook_namespace="test")
             self.client.get('/')
             self.assertEqual(env.call_count, 1)
             title = page.title_set.get(language="en")
             title.slug += 'test'
             title.save()
             page.publish('en')
             self.client.get('/')
             self.assertEqual(env.call_count, 2)
Example #10
0
 def test_urls_need_reloading_signal_change_slug(self):
     with apphooks(SampleApp):
         with signal_tester(urls_need_reloading) as env:
             self.assertEqual(env.call_count, 0)
             page = create_page(
                 "apphooked-page",
                 "nav_playground.html",
                 "en",
                 published=True,
                 apphook="SampleApp",
                 apphook_namespace="test"
             )
             self.client.get('/')
             self.assertEqual(env.call_count, 1)
             title = page.title_set.get(language="en")
             title.slug += 'test'
             title.save()
             page.publish('en')
             self.client.get('/')
             self.assertEqual(env.call_count, 2)
Example #11
0
 def test_uninstall_apphooks_with_apphook(self):
     with apphooks(SampleApp):
         out = io.StringIO()
         create_page('Hello Title',
                     "nav_playground.html",
                     "en",
                     apphook=APPHOOK)
         self.assertEqual(
             Page.objects.filter(application_urls=APPHOOK).count(), 1)
         management.call_command(
             "cms",
             "uninstall",
             "apphooks",
             APPHOOK,
             interactive=False,
             stdout=out,
         )
         self.assertEqual(out.getvalue(),
                          "1 'SampleApp' apphooks uninstalled\n")
         self.assertEqual(
             Page.objects.filter(application_urls=APPHOOK).count(), 0)