File: test_models.py

package info (click to toggle)
python-django 1.8.18-1~bpo8%2B1
  • links: PTS, VCS
  • area: main
  • in suites: jessie-backports
  • size: 41,628 kB
  • sloc: python: 189,488; xml: 695; makefile: 194; sh: 169; sql: 11
file content (22 lines) | stat: -rw-r--r-- 715 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# -*- coding: utf-8 -*-

from __future__ import unicode_literals

from django.contrib.flatpages.models import FlatPage
from django.core.urlresolvers import clear_script_prefix, set_script_prefix
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/')

    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()