From fa2e1234e92137b2b0c37a11ccc141081f1850d6 Mon Sep 17 00:00:00 2001 From: Keith Edmunds Date: Sat, 12 Feb 2022 23:34:00 +0000 Subject: [PATCH] Remove redundant functions and tests --- app/models.py | 23 ------------- app/musicmuster.py | 2 +- test_models.py | 83 +--------------------------------------------- 3 files changed, 2 insertions(+), 106 deletions(-) diff --git a/app/models.py b/app/models.py index 5d8f419..c402a74 100644 --- a/app/models.py +++ b/app/models.py @@ -269,23 +269,6 @@ class Playlists(Base): def __repr__(self): return f"" -# Not used - # def add_track(self, session, track, row=None): - # """ - # Add track to playlist at given row. - # If row=None, add to end of playlist - # """ - - # if not row: - # row = PlaylistTracks.new_row(session, self.id) - - # DEBUG(f"Playlists:add_track({session=}, {track=}, {row=})") - - # glue = PlaylistTracks(row=row) - # glue.track_id = track.id - # self.tracks.append(glue) - # session.commit() - def close(self, session): """Record playlist as no longer loaded""" @@ -324,17 +307,11 @@ class Playlists(Base): .order_by(cls.last_used.desc()) ).all() - #def get_notes(self): - # return [a.note for a in self.notes] - @classmethod def get_playlist_by_id(cls, session, playlist_id): return (session.query(cls).filter(cls.id == playlist_id)).one() - def get_tracks(self): - return [a.tracks for a in self.tracks] - @classmethod def new(cls, session, name): DEBUG(f"Playlists.new(name={name})") diff --git a/app/musicmuster.py b/app/musicmuster.py index 1044957..0a742b6 100755 --- a/app/musicmuster.py +++ b/app/musicmuster.py @@ -361,7 +361,7 @@ class Window(QMainWindow, Ui_MainWindow): with open(path, "w") as f: # Required directive on first line f.write("#EXTM3U\n") - for track in playlist_db.get_tracks(): + for track in playlist_db.tracks: f.write( "#EXTINF:" f"{int(track.duration / 1000)}," diff --git a/test_models.py b/test_models.py index 3d03871..95cd9d0 100644 --- a/test_models.py +++ b/test_models.py @@ -9,6 +9,7 @@ from app.models import ( Tracks, ) + def test_notecolours_get_colour(session): """Create a colour record and retrieve all colours""" @@ -42,67 +43,6 @@ def test_notecolours_get_by_id(session): assert record.colour == "abcdef" -# def test_notes_add_note(session): -# """Add and retrieve a note""" -# -# # We need to have a playlist to add the note to -# pl = Playlists() -# pl.name = "Test playlist" -# session.add(pl) -# session.commit() -# -# note_text = "Here we are" -# Notes.add_note(session, pl.id, 1, note_text) -# -# # We retrieve notes via playlist -# playlist = Playlists.get_playlist_by_id(session, pl.id) -# notes = playlist.get_notes() -# assert len(notes) == 1 -# assert notes[0] == note_text - - -# def test_notes_delete_note(session): -# """Add and delete a note""" -# -# # We need to have a playlist to add the note to -# pl = Playlists() -# pl.name = "Test playlist" -# session.add(pl) -# session.commit() -# -# note_text = "Here we are" -# rec = Notes.add_note(session, pl.id, 1, note_text) -# -# Notes.delete_note(session, rec.id) -# -# # We retrieve notes via playlist -# playlist = Playlists.get_playlist_by_id(session, pl.id) -# notes = playlist.get_notes() -# assert len(notes) == 0 - - -# def test_notes_update_note(session): -# """Add and update a note""" -# -# # We need to have a playlist to add the note to -# pl = Playlists() -# pl.name = "Test playlist" -# session.add(pl) -# session.commit() -# -# original_text = "Here we are" -# replacement_text = "There we go" -# rec = Notes.add_note(session, pl.id, 1, original_text) -# -# Notes.update_note(session, rec.id, 1, text=replacement_text) -# -# # We retrieve notes via playlist -# playlist = Playlists.get_playlist_by_id(session, pl.id) -# notes = playlist.get_notes() -# assert len(notes) == 1 -# assert notes[0] == replacement_text - - def test_playdates_add_playdate(session): """Test playdate and last_played retrieval""" @@ -136,27 +76,6 @@ def test_playdates_remove_track(session): assert last_played is None -# def test_playlist_add_track(session): -# """Test adding track to playlist""" -# -# # We need a track -# track_path = "/a/b/c" -# track = Tracks.get_or_create(session, track_path) -# # Need to commit because track record is updated in Playdates.add_playdate() -# session.commit() -# -# playlist = Playlists() -# playlist.name = "Test playlist" -# session.add(playlist) -# session.commit() -# -# playlist.add_track(session, track) -# -# tracks = playlist.get_tracks() -# assert len(tracks) == 1 -# assert tracks[0].path == track_path - - def test_playlist_close(session): """Test closing a playlist"""