def test_add_new_artwork(self): old_results = len(artwork_db.get_all_artwork()) aw1 = Artwork('Banksy', 'Mcdonald\'s is stealing your children', 138, True) artwork_db.add_artwork(aw1) results = len(artwork_db.get_all_artwork()) self.assertEquals(old_results + 1, results)
def test_delete_artwork_in_db(self): a1 = Artwork('sven', 'sven nude', 8311, True) artwork_db.add_artwork(a1) old_results = artwork_db.get_all_artwork() artwork_db.delete_artwork(a1.artwork_name) results = artwork_db.get_all_artists() self.assertEquals(len(old_results) - 1, len(results))
def name_of_artist(artwork_to_change): """grabs the name of the artist associated with either selling a piece or deleting to use to confirm with user before updating the DB""" current_artwork = artwork_db.get_all_artwork() for artwork in current_artwork: if artwork.artwork_name == artwork_to_change: return artwork.artist_name
def artwork_exists(artwork_query): """checks to ensure a piece of art is in the database""" current_artwork = artwork_db.get_all_artwork() titles = [] for artwork in current_artwork: titles.append(artwork.artwork_name.upper()) if artwork_query.upper() in titles: return True else: return False
def artwork_name_is_unique(artwork_name): """checks if an artwork name is unique""" current_artwork = artwork_db.get_all_artwork() titles = [] for artwork in current_artwork: titles.append(artwork.artwork_name.upper()) if artwork_name.upper() in titles: return False else: return True
def artist_has_work_in_db(artist_name): """checks if a registered artist has any work in DB""" current_artwork = artwork_db.get_all_artwork() names = [] for artwork in current_artwork: names.append(artwork.artist_name) if artist_name in names: return True else: return False
def test_get_all_artwork_one_artwork_in_db(self): aw1 = Artwork('Art Dood', 'Overpriced still life', 1138, True) artwork_db.add_artwork(aw1) result = artwork_db.get_all_artwork() self.assertEquals(1, len(result))
def display_all(): """prints all artwork for testing purposes""" results = artwork_db.get_all_artwork() for artist in results: print(artist)