def test_valid_url_multisite(self): site1 = Site.objects.get_current() site3 = Site.objects.create(domain="sample3.com", name="sample3.com") bar = create_page('bar', 'nav_playground.html', slug="bar", published=True, site=site1) bar_s3 = create_page('bar', 'nav_playground.html', slug="bar", published=True, site=site3) self.assertTrue(is_valid_url(bar.get_absolute_url(), bar)) self.assertTrue(is_valid_url(bar_s3.get_absolute_url(), bar_s3))
def test_slug_url_overwrite_clash(self): """ Tests if a URL-Override clashes with a normal page url """ with SettingsOverride(POSER_PERMISSION=False): bar = create_page('bar', 'nav_playground.html', published=False) foo = create_page('foo', 'nav_playground.html', published=True) # Tests to assure is_valid_url is ok on plain pages self.assertTrue(is_valid_url(bar.get_absolute_url(), bar)) self.assertTrue(is_valid_url(foo.get_absolute_url(), foo)) # Set url_overwrite for page foo foo.has_url_overwrite = True foo.path = '/bar/' foo.save() try: url = is_valid_url(bar.get_absolute_url(), bar) except ValidationError: url = False if url: bar.published = True bar.save() self.assertFalse(bar.published)
def test_slug_url_overwrite_clash(self): """ Tests if a URL-Override clashes with a normal page url """ with SettingsOverride(POSER_PERMISSION=False): bar = create_page('bar', 'nav_playground.html', published=False) foo = create_page('foo', 'nav_playground.html', published=True) # Tests to assure is_valid_url is ok on plain pages self.assertTrue(is_valid_url(bar.get_absolute_url(), bar)) self.assertTrue(is_valid_url(foo.get_absolute_url(), foo)) # Set url_overwrite for page foo foo.has_url_overwrite = True foo.path = '/bar/' foo.save() try: url = is_valid_url(bar.get_absolute_url(),bar) except ValidationError: url = False if url: bar.published = True bar.save() self.assertFalse(bar.published)