1
0
mirror of https://github.com/django/django.git synced 2024-12-23 09:36:06 +00:00
django/tests/flatpages_tests/test_models.py

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

32 lines
1.3 KiB
Python
Raw Normal View History

from django.contrib.flatpages.models import FlatPage
from django.test import SimpleTestCase, override_settings
from django.test.utils import override_script_prefix
class FlatpageModelTests(SimpleTestCase):
def setUp(self):
self.page = FlatPage(title="Café!", url="/café/")
def test_get_absolute_url_urlencodes(self):
self.assertEqual(self.page.get_absolute_url(), "/caf%C3%A9/")
@override_script_prefix("/prefix/")
def test_get_absolute_url_honors_script_prefix(self):
self.assertEqual(self.page.get_absolute_url(), "/prefix/caf%C3%A9/")
2017-10-12 12:56:05 +00:00
def test_str(self):
self.assertEqual(str(self.page), "/café/ -- Café!")
@override_settings(ROOT_URLCONF="flatpages_tests.urls")
def test_get_absolute_url_include(self):
self.assertEqual(self.page.get_absolute_url(), "/flatpage_root/caf%C3%A9/")
@override_settings(ROOT_URLCONF="flatpages_tests.no_slash_urls")
def test_get_absolute_url_include_no_slash(self):
self.assertEqual(self.page.get_absolute_url(), "/flatpagecaf%C3%A9/")
@override_settings(ROOT_URLCONF="flatpages_tests.absolute_urls")
def test_get_absolute_url_with_hardcoded_url(self):
fp = FlatPage(title="Test", url="/hardcoded/")
self.assertEqual(fp.get_absolute_url(), "/flatpage/")