diff bio/tests/form_tests.py @ 612:5be850a66dfc

For BB issue 17, validate timezone values when saving user profiles.
author Brian Neal <bgneal@gmail.com>
date Sun, 12 Aug 2012 09:34:56 -0500
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bio/tests/form_tests.py	Sun Aug 12 09:34:56 2012 -0500
@@ -0,0 +1,28 @@
+"""
+Form tests for the bio application.
+
+"""
+from django.test import TestCase
+
+from bio.forms import EditUserProfileForm
+
+
+class EditUserProfileFormTestCase(TestCase):
+
+    def test_valid_timezone(self):
+        
+        post_data = {'time_zone': 'US/Central'}
+        form = EditUserProfileForm(post_data)
+        self.assertTrue(form.is_valid())
+
+    def test_invalid_timezone(self):
+        
+        post_data = {'time_zone': u'Am\xe9rica/Argentina_/_Buenos_Aires'}
+        form = EditUserProfileForm(post_data)
+        self.assertFalse(form.is_valid())
+
+    def test_blank_timezone(self):
+        
+        form = EditUserProfileForm({})
+        self.assertTrue(form.is_valid())
+