def test_user_can_add_empty_data(self): user = User(username='******', email='*****@*****.**') user.save() form_data = { 'twitter_username': None, 'bio': None, 'favorite_artist': None, 'favorite_show': None } form = ProfileForm(form_data) self.assertTrue(form.is_valid())
def test_user_can_add_filled_data(self): user = User(username='******', email='*****@*****.**') user.save() artist = Artist(name='Nym', hometown='Place', description='A Band') artist.save() venue = Venue(name='Arena', address='123 Location') venue.save() show = Show(show_date=datetime.now(), artist=artist, venue=venue) show.save() form_data = { 'twitter_username': '******', 'bio': 'Fake biography.', 'favorite_artist': artist, 'favorite_show': show } form = ProfileForm(form_data) self.assertTrue(form.is_valid())
def test_twitter_username_must_be_under_15_characters(self): user = User(username='******', email='*****@*****.**') user.save() form_data = { 'thisis==15chars': None, 'bio': None, 'favorite_artist': None, 'favorite_show': None } form = ProfileForm(form_data) self.assertTrue(form.is_valid()) form_data = { 'thisis==sixteen!': None, 'bio': None, 'favorite_artist': None, 'favorite_show': None } form = ProfileForm(form_data) self.assertTrue(form.is_valid())
def test_location_is_empty(self): empty = '' form_data = {"location": empty} form = ProfileForm(form_data) self.assertTrue(form.is_valid())
def test_favorite_artist_long_is_invalid(self): # Max length is 200 form_data = {"favorite_artist": "a" * 201} form = ProfileForm(form_data) self.assertFalse(form.is_valid())
def test_bio_too_long_is_invalid(self): # Max length is 500 form_data = {"bio": "a" * 501} form = ProfileForm(form_data) self.assertFalse(form.is_valid())
def test_empty_is_invalid(self): empty = '' form_data = {"bio": empty} form = ProfileForm(form_data) self.assertTrue(form.is_valid())
def test_more_than_500_characters_is_invalid(self): five01 = 'a' * 501 form_data = {"bio": five01} form = ProfileForm(form_data) self.assertFalse(form.is_valid())