trackdb: Add Track class
I don't read tags yet, but I set up some other variables that will be useful later. Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
parent
c46f73cbc6
commit
7afa16b57d
|
@ -0,0 +1,23 @@
|
|||
# Copyright 2020 (c) Anna Schumaker.
|
||||
from . import track
|
||||
import datetime
|
||||
import pathlib
|
||||
import unittest
|
||||
|
||||
test_tracks = pathlib.Path("./trier/Test Album")
|
||||
|
||||
class TestTrack(unittest.TestCase):
|
||||
def test_track_init(self):
|
||||
trak = track.Track(1, test_tracks / "01 - Test Track.ogg")
|
||||
self.assertEqual(trak.trackid, 1)
|
||||
self.assertEqual(trak.filepath, test_tracks / "01 - Test Track.ogg")
|
||||
self.assertEqual(trak.playcount, 0)
|
||||
self.assertIsNone(trak.lastplayed)
|
||||
|
||||
def test_track_played(self):
|
||||
trak = track.Track(1, test_tracks / "01 - Test Track.ogg")
|
||||
trak.played()
|
||||
self.assertEqual(trak.playcount, 1)
|
||||
self.assertEqual(trak.lastplayed, datetime.date.today())
|
||||
trak.played()
|
||||
self.assertEqual(trak.playcount, 2)
|
|
@ -0,0 +1,13 @@
|
|||
# Copyright 2020 (c) Anna Schumaker.
|
||||
import datetime
|
||||
|
||||
class Track:
|
||||
def __init__(self, trackid, filepath):
|
||||
self.trackid = trackid
|
||||
self.filepath = filepath
|
||||
self.playcount = 0
|
||||
self.lastplayed = None
|
||||
|
||||
def played(self):
|
||||
self.playcount += 1
|
||||
self.lastplayed = datetime.date.today()
|
Loading…
Reference in New Issue