2014-05-15 17:41:55 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
2013-02-24 12:12:41 +00:00
|
|
|
|
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
|
|
|
from django.contrib.flatpages.models import FlatPage
|
2015-01-28 12:35:27 +00:00
|
|
|
from django.core.urlresolvers import clear_script_prefix, set_script_prefix
|
2013-02-24 12:12:41 +00:00
|
|
|
from django.test import TestCase
|
|
|
|
|
|
|
|
|
|
|
|
class FlatpageModelTests(TestCase):
|
|
|
|
|
|
|
|
def test_get_absolute_url_urlencodes(self):
|
|
|
|
pf = FlatPage(title="Café!", url='/café/')
|
|
|
|
self.assertEqual(pf.get_absolute_url(), '/caf%C3%A9/')
|
|
|
|
|
2013-02-24 12:25:17 +00:00
|
|
|
def test_get_absolute_url_honors_script_prefix(self):
|
|
|
|
pf = FlatPage(title="Tea!", url='/tea/')
|
|
|
|
set_script_prefix('/beverages/')
|
|
|
|
try:
|
|
|
|
self.assertEqual(pf.get_absolute_url(), '/beverages/tea/')
|
|
|
|
finally:
|
|
|
|
clear_script_prefix()
|