bgneal@612: """ bgneal@612: Form tests for the bio application. bgneal@612: bgneal@612: """ bgneal@612: from django.test import TestCase bgneal@612: bgneal@612: from bio.forms import EditUserProfileForm bgneal@612: bgneal@612: bgneal@612: class EditUserProfileFormTestCase(TestCase): bgneal@612: bgneal@612: def test_valid_timezone(self): bgneal@744: bgneal@612: post_data = {'time_zone': 'US/Central'} bgneal@612: form = EditUserProfileForm(post_data) bgneal@612: self.assertTrue(form.is_valid()) bgneal@612: bgneal@612: def test_invalid_timezone(self): bgneal@744: bgneal@612: post_data = {'time_zone': u'Am\xe9rica/Argentina_/_Buenos_Aires'} bgneal@612: form = EditUserProfileForm(post_data) bgneal@612: self.assertFalse(form.is_valid()) bgneal@612: bgneal@612: def test_blank_timezone(self): bgneal@744: bgneal@612: form = EditUserProfileForm({}) bgneal@612: self.assertTrue(form.is_valid()) bgneal@612: bgneal@1011: def test_profile_text_good(self): bgneal@1011: post_data = {'profile_text': "This is my profile, no images."} bgneal@1011: form = EditUserProfileForm(post_data) bgneal@1011: self.assertTrue(form.is_valid()) bgneal@1011: bgneal@1011: def test_profile_text_bad_image(self): bgneal@1011: post_data = { bgneal@1011: 'profile_text': "I'm cool. ![image](http://example.com/test.jpg)", bgneal@1011: } bgneal@1011: form = EditUserProfileForm(post_data) bgneal@1011: self.assertFalse(form.is_valid()) bgneal@1011: bgneal@1011: def test_signature_good(self): bgneal@1011: post_data = {'signature': "This is my signature, no images."} bgneal@1011: form = EditUserProfileForm(post_data) bgneal@1011: self.assertTrue(form.is_valid()) bgneal@1011: bgneal@1011: def test_signature_bad_image(self): bgneal@1011: post_data = { bgneal@1011: 'signature': "I'm cool. ![image](http://example.com/test.jpg)", bgneal@1011: } bgneal@1011: form = EditUserProfileForm(post_data) bgneal@1011: self.assertFalse(form.is_valid())