Example #1
0
 def test_twitter_fine(self):
     form = BasePersonForm({
         'name': 'John Doe',
         'twitter_username': '******',
     })
     self.assertTrue(form.is_valid())
     self.assertEqual(form.errors, {})
     self.assertEqual(form.cleaned_data['twitter_username'],
                      'madeuptwitteraccount')
Example #2
0
 def test_malformed_email(self):
     form = BasePersonForm({
         'name': 'John Bercow',
         'email': 'foo bar!',
     },
                           initial={
                               'person': self.person,
                           })
     self.assertFalse(form.is_valid())
     self.assertEqual(form.errors,
                      {'email': ['Enter a valid email address.']})
Example #3
0
 def test_twitter_bad_url(self):
     form = BasePersonForm({
         'name': 'John Doe',
         'twitter_username': '******',
     })
     self.assertFalse(form.is_valid())
     self.assertEqual(
         form.errors, {
             'twitter_username': [
                 'The Twitter username must only consist of alphanumeric characters or underscore'
             ]
         })