PageRenderTime 44ms CodeModel.GetById 19ms RepoModel.GetById 0ms 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
Possible License(s): BSD-3-Clause
  1. from django.conf import settings
  2. from django.contrib.flatpages.admin import FlatpageForm
  3. from django.test import TestCase
  4. class FlatpageAdminFormTests(TestCase):
  5. def setUp(self):
  6. self.form_data = {
  7. 'title': "A test page",
  8. 'content': "This is a test",
  9. 'sites': [settings.SITE_ID],
  10. }
  11. def test_flatpage_admin_form_url_validation(self):
  12. "The flatpage admin form validates correctly validates urls"
  13. self.assertTrue(FlatpageForm(data=dict(url='/new_flatpage/', **self.form_data)).is_valid())
  14. self.assertTrue(FlatpageForm(data=dict(url='/some.special~chars/', **self.form_data)).is_valid())
  15. self.assertTrue(FlatpageForm(data=dict(url='/some.very_special~chars-here/', **self.form_data)).is_valid())
  16. self.assertFalse(FlatpageForm(data=dict(url='/a space/', **self.form_data)).is_valid())
  17. self.assertFalse(FlatpageForm(data=dict(url='/a % char/', **self.form_data)).is_valid())
  18. self.assertFalse(FlatpageForm(data=dict(url='/a ! char/', **self.form_data)).is_valid())
  19. self.assertFalse(FlatpageForm(data=dict(url='/a & char/', **self.form_data)).is_valid())
  20. self.assertFalse(FlatpageForm(data=dict(url='/a ? char/', **self.form_data)).is_valid())