예제 #1
0
 def test_not_empty(self):
     session, _ = self.scan_directory('mp3s')
     albums = session.query(Album).join(Album.tracks).join(Track.artist).filter(Artist.name == 'Artist 1').all()
     assert len(albums) == 1, albums
     album = albums[0]
     assert album.path == join(parent(__file__), 'mp3s', 'Artist 1', 'Album 1'), album.path
     assert len(album.tracks) == 2, album.tracks
     tracks = lfilter(lambda t: t.number == 1, album.tracks)
     assert len(tracks) == 1, tracks
     track = tracks[0]
     tracks = session.query(Track).all()
     assert len(tracks) == 7, len(tracks)
     tracks = session.query(Track).join(Track.artist).filter(Track.number == 1, Artist.name == 'Artist 1').all()
     assert len(tracks) == 1, len(tracks)
     assert track == tracks[0]
     assert track.name == 'Track 1', track.name
     assert track.file == 'Artist 1 - 01 - Track 1.mp3', track.file
     artists = session.query(Artist).filter(Artist.name == 'Artist 1').all()
     assert len(artists) == 1, len(artists)
     artist = artists[0]
     assert track.artist == artist, track.artist
     assert artist.name == 'Artist 1', artist.name
     assert len(artist.tracks) == 2, len(artist.tracks)
예제 #2
0
    def scan_directory(self, file):
        config = Config(mp3_path=join(parent(__file__), file), db_url='sqlite:///')
#        config = Config(mp3_path=join(parent(__file__), file), db_url='sqlite:////tmp/test.sql')
        session = startup(config)
        scan_all(session, DummyFinder(), config)
        return session, config