Anna Schumaker
b316184bf1
This class combines a header with an initially hidden ListView that can be configured to list our playlists. It also implements "playlist-activated" and "playlist-selected" signals to signal user interaction. Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
35 lines
1.1 KiB
Python
35 lines
1.1 KiB
Python
# Copyright 2023 (c) Anna Schumaker.
|
|
"""Mock Playlist and Table objects for testing."""
|
|
import emmental.db.playlist
|
|
import sqlite3
|
|
from gi.repository import GObject
|
|
|
|
|
|
class MockPlaylist(emmental.db.playlist.Playlist):
|
|
"""A fake Playlist for testing."""
|
|
|
|
parent = GObject.Property(type=emmental.db.playlist.Playlist)
|
|
|
|
@property
|
|
def primary_key(self) -> int:
|
|
"""Get the primary_key of this playlist."""
|
|
return self.propertyid
|
|
|
|
|
|
class MockTable(emmental.db.playlist.Table):
|
|
"""A fake Playlist Table for testing."""
|
|
|
|
def do_construct(self, **kwargs) -> MockPlaylist:
|
|
"""Construct a new Playlist object."""
|
|
return MockPlaylist(**kwargs)
|
|
|
|
def do_sql_delete(self, playlist: MockPlaylist) -> sqlite3.Cursor:
|
|
"""Extra work for deleting a Playlist."""
|
|
return self.sql("DELETE FROM playlist_properties WHERE propertyid=?",
|
|
playlist.propertyid)
|
|
|
|
def do_sql_insert(self, name: str) -> sqlite3.Cursor:
|
|
"""Extra work for adding a new Playlist."""
|
|
return self.sql("""INSERT INTO playlist_properties DEFAULT VALUES
|
|
RETURNING ? as name, *""", name)
|