def test_where_returns_correct_keys(): row = MusicTracks.where({'album_title': 'KONTRAST'})[0] keys = [ 'track_id', 'album_id', 'album_title', 'album_url', 'artist_id', 'artist_name', 'artist_url', 'track_date_created', 'track_duration', 'track_listens', 'track_title', 'track_url' ] values = [ '56482', '10439', 'KONTRAST', 'http://freemusicarchive.org/music/KVZE/KONTRAST/', '12270', 'KVZE', 'http://freemusicarchive.org/music/KVZE/', '11/16/2011 03:54:59 PM', '02:21', '1047', 'Scotch', 'http://freemusicarchive.org/music/KVZE/KONTRAST/08_kvze_-_scotch' ] for i in range(0, len(keys)): assert row[keys[i]] == values[i]
def test_where_returns_no_tracks(): assert len(MusicTracks.where({'track_title': 'NotExistentTitle'})) == 0
def test_where_returns_tracks_by_title(): assert len(MusicTracks.where({'track_title': 'Introduction'})) == 2
def test_where_returns_tracks_per_album(): assert len(MusicTracks.where({'album_title': 'Kung Flu'})) == 5
def test_where_returns_tracks_by_listens(): assert len(MusicTracks.where({'track_listens': '842'})) == 4
def test_where_returns_tracks_by_artist_name(): assert len(MusicTracks.where({'artist_name': 'The Loving Knives'})) == 6