Пример #1
0
    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())
Пример #2
0
    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())
Пример #3
0
    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())
Пример #4
0
 def test_location_is_empty(self):
     empty = ''
     form_data = {"location": empty}
     form = ProfileForm(form_data)
     self.assertTrue(form.is_valid())
Пример #5
0
 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())
Пример #6
0
 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())
Пример #7
0
 def test_empty_is_invalid(self):
     empty = ''
     form_data = {"bio": empty}
     form = ProfileForm(form_data)
     self.assertTrue(form.is_valid())
Пример #8
0
 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())