From 7f046ae86b9e2fc407f6ae2086ce70810a789291 Mon Sep 17 00:00:00 2001 From: Keith Edmunds Date: Mon, 14 Mar 2022 21:40:15 +0000 Subject: [PATCH] test_playlists complete and working --- app/models.py | 4 ++-- test_models.py | 17 ++++++++--------- test_playlists.py | 4 ++-- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/app/models.py b/app/models.py index f6304e7..c7fc811 100644 --- a/app/models.py +++ b/app/models.py @@ -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. """ diff --git a/test_models.py b/test_models.py index 8ab5769..c96bf6b 100644 --- a/test_models.py +++ b/test_models.py @@ -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'] diff --git a/test_playlists.py b/test_playlists.py index 8866227..7d55b51 100644 --- a/test_playlists.py +++ b/test_playlists.py @@ -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):