def delete(*, artist: ArtistModel = None, name: str = None) -> None: assert artist or name if not artist: artist = ArtistModel.read(name=name) artist.delete()
def getDummyArtist(): artist = Artist() artist.name='JUANA BOTERO' artist.pictureUrl='../static/img/artist.jpg' #artist.pictureUrl='http://www.laparaulatailustrada.com/wp-content/uploads/2010/10/juancalzadilla_jpg.jpg' artist.description='' return artist
def populate_db(): with session_scope(): for artist_data in test_data: artist = Artist(name=artist_data["name"]) for album_data in artist_data["albums"]: album = Album(**album_data) artist.albums.append(album) artist.save()
def library_one_artist(library, first_artist): artist = Artist(name=first_artist.name) with session_scope(): library.artists.create(artist=artist) return library
def test_no_albums_init(data): """Check to make sure that two different empty artists don't have the same list of albums.""" # given artist_name_1 = data[0]["name"] artist_name_2 = data[1]["name"] # execute artist_1 = Artist(name=artist_name_1) artist_2 = Artist(name=artist_name_2) # expect assert artist_1.albums is not artist_2.albums artist_1.albums.append(Album(name="abc", year=2000)) assert 1 == len(artist_1.albums) assert 0 == len(artist_2.albums)
def select_all(): artists = [] sql = "SELECT * FROM artists" results = run_sql(sql) for row in results: artist = Artist(row['name'], row['id']) artists.append(artist) return artists
def test_add_existing_artist(library_one_artist, first_artist): # given library = library_one_artist artist_name = first_artist["name"] artist = Artist(name=artist_name) # execute / expect with pytest.raises(ValueError): library.artists.create(artist=artist)
def test_init(): # given # execute artist = Artist(name="artist", albums=[]) # expect assert "artist" == artist.name assert 0 == len(artist.albums)
def test_add_existing_artist(library_one_artist, first_artist): # given library = library_one_artist artist = Artist(name=first_artist["name"]) # execute / expect with pytest.raises(AlreadyExistsException) as e: with session_scope(): library.artists.create(artist=artist) assert first_artist["name"] in str(e.value)
def create(*, album: AlbumModel, artist: ArtistModel = None, artist_name: str = None) -> None: assert artist or artist_name if not artist: artist = ArtistModel.read(name=artist_name) artist.albums.append(album) album.save()
def test_add_artist(library, first_artist): # given artist_name = first_artist["name"] artist = Artist(name=artist_name) # execute library.artists.create(artist=artist) # expect artist_result = library.artists.read(name=artist_name) assert artist_result assert artist.name == artist_result.name
def test_add_artist(library, first_artist): # given artist = Artist(name=first_artist["name"]) # execute with session_scope(): library.artists.create(artist=artist) # expect artist_result = library.artists.read(name=first_artist["name"]) assert artist_result assert first_artist["name"] == artist_result.name
def test_init(first_artist): # given albums = [] for album in first_artist["albums"]: albums.append(Album(**album)) artist_name = first_artist["name"] # execute artist = Artist(name=artist_name, albums=albums) # expect assert artist_name == artist.name assert len(first_artist["albums"]) == len(artist.albums)
import pdb from model.album import Album from model.artist import Artist import repositories.artist_repository as artist_repository import repositories.album_repository as album_repository artist_1 = Artist("Adele") artist_repository.save(artist_1) artist_2 = Artist("The Beatles") artist_repository.save(artist_2) album_1 = Album("21", "Pop", artist_1) album_repository.save(album_1) album_2 = Album("Sgt Pepper", "Pop", artist_2) album_repository.save(album_2) album_3 = Album("19", "Pop", artist_1) album_repository.save(album_3) album_4 = Album("25", "Pop", artist_1) album_repository.save(album_4) results = album_repository.albums_by_artist(artist_1) for result in results: print(result.__dict__) artist = album_repository.artist_by_album(album_1) print(artist) pdb.set_trace()
def library_one_artist(library, first_artist): artist = Artist(name=first_artist["name"]) library.artists.create(artist=artist) return library
def list() -> List[ArtistModel]: return ArtistModel.list()
def create(*, artist: ArtistModel) -> None: artist.save()
def test_create_recording_artist(app): app.artist.create_recording_artist( Artist(name="ra_#1", note="Tranquillitatis est in vobis. Nec foris quaereret."))
def first_artist(data): artist = Artist(name=test_data[0]["name"]) return artist
def read(*, name: str) -> Union[ArtistModel, None]: return ArtistModel.read(name=name)