bgneal@612
|
1 """
|
bgneal@612
|
2 Form tests for the bio application.
|
bgneal@612
|
3
|
bgneal@612
|
4 """
|
bgneal@612
|
5 from django.test import TestCase
|
bgneal@612
|
6
|
bgneal@612
|
7 from bio.forms import EditUserProfileForm
|
bgneal@612
|
8
|
bgneal@612
|
9
|
bgneal@612
|
10 class EditUserProfileFormTestCase(TestCase):
|
bgneal@612
|
11
|
bgneal@612
|
12 def test_valid_timezone(self):
|
bgneal@744
|
13
|
bgneal@612
|
14 post_data = {'time_zone': 'US/Central'}
|
bgneal@612
|
15 form = EditUserProfileForm(post_data)
|
bgneal@612
|
16 self.assertTrue(form.is_valid())
|
bgneal@612
|
17
|
bgneal@612
|
18 def test_invalid_timezone(self):
|
bgneal@744
|
19
|
bgneal@612
|
20 post_data = {'time_zone': u'Am\xe9rica/Argentina_/_Buenos_Aires'}
|
bgneal@612
|
21 form = EditUserProfileForm(post_data)
|
bgneal@612
|
22 self.assertFalse(form.is_valid())
|
bgneal@612
|
23
|
bgneal@612
|
24 def test_blank_timezone(self):
|
bgneal@744
|
25
|
bgneal@612
|
26 form = EditUserProfileForm({})
|
bgneal@612
|
27 self.assertTrue(form.is_valid())
|
bgneal@612
|
28
|
bgneal@1011
|
29 def test_profile_text_good(self):
|
bgneal@1011
|
30 post_data = {'profile_text': "This is my profile, no images."}
|
bgneal@1011
|
31 form = EditUserProfileForm(post_data)
|
bgneal@1011
|
32 self.assertTrue(form.is_valid())
|
bgneal@1011
|
33
|
bgneal@1011
|
34 def test_profile_text_bad_image(self):
|
bgneal@1011
|
35 post_data = {
|
bgneal@1011
|
36 'profile_text': "I'm cool. ![image](http://example.com/test.jpg)",
|
bgneal@1011
|
37 }
|
bgneal@1011
|
38 form = EditUserProfileForm(post_data)
|
bgneal@1011
|
39 self.assertFalse(form.is_valid())
|
bgneal@1011
|
40
|
bgneal@1011
|
41 def test_signature_good(self):
|
bgneal@1011
|
42 post_data = {'signature': "This is my signature, no images."}
|
bgneal@1011
|
43 form = EditUserProfileForm(post_data)
|
bgneal@1011
|
44 self.assertTrue(form.is_valid())
|
bgneal@1011
|
45
|
bgneal@1011
|
46 def test_signature_bad_image(self):
|
bgneal@1011
|
47 post_data = {
|
bgneal@1011
|
48 'signature': "I'm cool. ![image](http://example.com/test.jpg)",
|
bgneal@1011
|
49 }
|
bgneal@1011
|
50 form = EditUserProfileForm(post_data)
|
bgneal@1011
|
51 self.assertFalse(form.is_valid())
|