PageRenderTime 18ms CodeModel.GetById 14ms app.highlight 2ms RepoModel.GetById 2ms app.codeStats 0ms

/django/contrib/flatpages/tests/forms.py

https://code.google.com/p/mango-py/
Python | 23 lines | 20 code | 3 blank | 0 comment | 0 complexity | 3fd716b1ac6a69b282d85415a5dd3861 MD5 | raw file
 1from django.conf import settings
 2from django.contrib.flatpages.admin import FlatpageForm
 3from django.test import TestCase
 4
 5class FlatpageAdminFormTests(TestCase):
 6    def setUp(self):
 7        self.form_data = {
 8            'title': "A test page",
 9            'content': "This is a test",
10            'sites': [settings.SITE_ID],
11        }
12
13    def test_flatpage_admin_form_url_validation(self):
14        "The flatpage admin form validates correctly validates urls"
15        self.assertTrue(FlatpageForm(data=dict(url='/new_flatpage/', **self.form_data)).is_valid())
16        self.assertTrue(FlatpageForm(data=dict(url='/some.special~chars/', **self.form_data)).is_valid())
17        self.assertTrue(FlatpageForm(data=dict(url='/some.very_special~chars-here/', **self.form_data)).is_valid())
18
19        self.assertFalse(FlatpageForm(data=dict(url='/a space/', **self.form_data)).is_valid())
20        self.assertFalse(FlatpageForm(data=dict(url='/a % char/', **self.form_data)).is_valid())
21        self.assertFalse(FlatpageForm(data=dict(url='/a ! char/', **self.form_data)).is_valid())
22        self.assertFalse(FlatpageForm(data=dict(url='/a & char/', **self.form_data)).is_valid())
23        self.assertFalse(FlatpageForm(data=dict(url='/a ? char/', **self.form_data)).is_valid())