def test_add_artist_with_duplicate_name(self): self.remake_tables() ats1 = Artist(name='ats1', email_address='*****@*****.**') add_artist(ats1) ats2 = Artist(name='ats1', email_address='*****@*****.**') with self.assertRaises(ArtistError): add_artist(ats2)
def test_add_artist_not_empty_database(self): self.remake_tables() ats1 = Artist(name='ats1', email_address='*****@*****.**') add_artist(ats1) ats2 = Artist(name='ats2', email_address='*****@*****.**') add_artist(ats2) fetch_ats2 = Artist.select().where(Artist.name == 'ats2') self.assertTrue(ats2 == fetch_ats2[0])
def create_artist_submission(): # called upon submitting the new artist listing form # TODO: insert form data as a new Venue record in the db, instead form = ArtistForm() error = False try: artist = Artist() form.populate_obj(artist) db.session.add(artist) db.session.commit() except: error = True db.session.rollback() flash('An error occurred. Artist ' + artist.name + ' could not be listed.') finally: db.session.close() if not error: flash('Artist ' + request.form['name'] + ' was successfully listed!') # TODO: modify data to be the data object returned from db insertion # on successful db insert, flash success # TODO: on unsuccessful db insert, flash an error instead. return render_template('pages/home.html')
def test_get_artist_by_nonexistant_id(self): self.remake_tables() ats1 = Artist(name='ats1', email_address='*****@*****.**') add_artist(ats1) self.assertEqual(get_artist_id('ats1'), 1)
def test_get_artist_by_id(self): self.remake_tables() ats1 = Artist(name='ats1', email_address='*****@*****.**') add_artist(ats1) fetch_artist = get_artist_id('ats1') self.assertEqual(ats1.id, fetch_artist)
def test_add_artist_missing_data(self): self.remake_tables() ats1 = Artist(name='ats1') with self.assertRaises(ArtistError): add_artist(ats1)