Remove redundant functions and tests
This commit is contained in:
parent
fec45925c6
commit
fa2e1234e9
@ -269,23 +269,6 @@ class Playlists(Base):
|
|||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return f"<Playlists(id={self.id}, name={self.name}>"
|
return f"<Playlists(id={self.id}, name={self.name}>"
|
||||||
|
|
||||||
# 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):
|
def close(self, session):
|
||||||
"""Record playlist as no longer loaded"""
|
"""Record playlist as no longer loaded"""
|
||||||
|
|
||||||
@ -324,17 +307,11 @@ class Playlists(Base):
|
|||||||
.order_by(cls.last_used.desc())
|
.order_by(cls.last_used.desc())
|
||||||
).all()
|
).all()
|
||||||
|
|
||||||
#def get_notes(self):
|
|
||||||
# return [a.note for a in self.notes]
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_playlist_by_id(cls, session, playlist_id):
|
def get_playlist_by_id(cls, session, playlist_id):
|
||||||
|
|
||||||
return (session.query(cls).filter(cls.id == playlist_id)).one()
|
return (session.query(cls).filter(cls.id == playlist_id)).one()
|
||||||
|
|
||||||
def get_tracks(self):
|
|
||||||
return [a.tracks for a in self.tracks]
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def new(cls, session, name):
|
def new(cls, session, name):
|
||||||
DEBUG(f"Playlists.new(name={name})")
|
DEBUG(f"Playlists.new(name={name})")
|
||||||
|
|||||||
@ -361,7 +361,7 @@ class Window(QMainWindow, Ui_MainWindow):
|
|||||||
with open(path, "w") as f:
|
with open(path, "w") as f:
|
||||||
# Required directive on first line
|
# Required directive on first line
|
||||||
f.write("#EXTM3U\n")
|
f.write("#EXTM3U\n")
|
||||||
for track in playlist_db.get_tracks():
|
for track in playlist_db.tracks:
|
||||||
f.write(
|
f.write(
|
||||||
"#EXTINF:"
|
"#EXTINF:"
|
||||||
f"{int(track.duration / 1000)},"
|
f"{int(track.duration / 1000)},"
|
||||||
|
|||||||
@ -9,6 +9,7 @@ from app.models import (
|
|||||||
Tracks,
|
Tracks,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_notecolours_get_colour(session):
|
def test_notecolours_get_colour(session):
|
||||||
"""Create a colour record and retrieve all colours"""
|
"""Create a colour record and retrieve all colours"""
|
||||||
|
|
||||||
@ -42,67 +43,6 @@ def test_notecolours_get_by_id(session):
|
|||||||
assert record.colour == "abcdef"
|
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):
|
def test_playdates_add_playdate(session):
|
||||||
"""Test playdate and last_played retrieval"""
|
"""Test playdate and last_played retrieval"""
|
||||||
|
|
||||||
@ -136,27 +76,6 @@ def test_playdates_remove_track(session):
|
|||||||
assert last_played is None
|
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):
|
def test_playlist_close(session):
|
||||||
"""Test closing a playlist"""
|
"""Test closing a playlist"""
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user