test_playlists complete and working
This commit is contained in:
parent
a27dd7189a
commit
7f046ae86b
@ -511,7 +511,7 @@ class Tracks(Base):
|
||||
return track
|
||||
|
||||
@classmethod
|
||||
def get_from_filename(cls, session: Session, filename: str) \
|
||||
def get_by_filename(cls, session: Session, filename: str) \
|
||||
-> Optional["Tracks"]:
|
||||
"""
|
||||
Return track if one and only one track in database has passed
|
||||
@ -528,7 +528,7 @@ class Tracks(Base):
|
||||
return None
|
||||
|
||||
@classmethod
|
||||
def get_from_path(cls, session: Session, path: str) -> List["Tracks"]:
|
||||
def get_by_path(cls, session: Session, path: str) -> List["Tracks"]:
|
||||
"""
|
||||
Return track with passee path, or None.
|
||||
"""
|
||||
|
||||
@ -308,7 +308,7 @@ def test_playlist_get_track_playlists(session):
|
||||
assert p2_name not in [a.playlist.name for a in playlists_track2]
|
||||
|
||||
|
||||
def test_playlisttracks_move_track(session):
|
||||
def test_playlist_move_track(session):
|
||||
# We need two playlists
|
||||
p1_name = "playlist one"
|
||||
p2_name = "playlist two"
|
||||
@ -322,7 +322,6 @@ def test_playlisttracks_move_track(session):
|
||||
track2_row = 29
|
||||
track2_path = "/m/n/o"
|
||||
track2 = Tracks(session, track2_path)
|
||||
track1 = Tracks(session, track1_path)
|
||||
|
||||
# Add both to playlist1 and check
|
||||
playlist1.add_track(session, track1.id, track1_row)
|
||||
@ -346,9 +345,9 @@ def test_playlisttracks_move_track(session):
|
||||
def test_tracks_get_all_paths(session):
|
||||
# Need two tracks
|
||||
track1_path = "/a/b/c"
|
||||
track1 = Tracks(session, track1_path)
|
||||
_ = Tracks(session, track1_path)
|
||||
track2_path = "/m/n/o"
|
||||
track2 = Tracks(session, track2_path)
|
||||
_ = Tracks(session, track2_path)
|
||||
|
||||
result = Tracks.get_all_paths(session)
|
||||
assert track1_path in result
|
||||
@ -376,20 +375,20 @@ def test_tracks_get_or_create(session):
|
||||
assert track1 is track2
|
||||
|
||||
|
||||
def test_tracks_from_filename(session):
|
||||
def test_tracks_by_filename(session):
|
||||
track1_path = "/a/b/c"
|
||||
|
||||
track1 = Tracks(session, track1_path)
|
||||
assert Tracks.get_from_filename(
|
||||
assert Tracks.get_by_filename(
|
||||
session, os.path.basename(track1_path)
|
||||
) is track1
|
||||
|
||||
|
||||
def test_tracks_from_path(session):
|
||||
def test_tracks_by_path(session):
|
||||
track1_path = "/a/b/c"
|
||||
|
||||
track1 = Tracks(session, track1_path)
|
||||
assert Tracks.get_from_path(session, track1_path) is track1
|
||||
assert Tracks.get_by_path(session, track1_path) is track1
|
||||
|
||||
|
||||
def test_tracks_by_id(session):
|
||||
@ -412,7 +411,7 @@ def test_tracks_rescan(session):
|
||||
testdata = eval(f.read())
|
||||
|
||||
# Re-read the track
|
||||
track_read = Tracks.get_from_path(session, test_track_path)
|
||||
track_read = Tracks.get_by_path(session, test_track_path)
|
||||
|
||||
assert track_read.duration == testdata['duration']
|
||||
assert track_read.start_gap == testdata['leading_silence']
|
||||
|
||||
@ -247,9 +247,9 @@ def test_set_next(qtbot, monkeypatch, session):
|
||||
qtbot.addWidget(playlist_tab)
|
||||
|
||||
# Add some tracks
|
||||
track1 = models.Tracks.get_from_filename(session, "isa.mp3")
|
||||
track1 = models.Tracks.get_by_filename(session, "isa.mp3")
|
||||
playlist_tab.insert_track(session, track1)
|
||||
track2 = models.Tracks.get_from_filename(session, "mom.mp3")
|
||||
track2 = models.Tracks.get_by_filename(session, "mom.mp3")
|
||||
playlist_tab.insert_track(session, track2)
|
||||
|
||||
with qtbot.waitExposed(window):
|
||||
|
||||
Loading…
Reference in New Issue
Block a user