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')
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.']})
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' ] })