diff --git a/nowplaying/show/show.py b/nowplaying/show/show.py index 6d35ed12..1d0e7de9 100644 --- a/nowplaying/show/show.py +++ b/nowplaying/show/show.py @@ -3,41 +3,29 @@ import logging.handlers import uuid -import pytz +from nowplaypadgen.show import Show as PadGenShow, ShowError as PadGenShowError logger = logging.getLogger(__name__) DEFAULT_SHOW_URL = "https://www.rabe.ch" -class ShowError(Exception): +class ShowError(PadGenShowError): """Show related exception.""" - pass - -class Show: +class Show(PadGenShow): """Show object which has a start and end time and an optional URL.""" def __init__(self): - self.name = None + """Initialize a new Show object.""" + super().__init__() self.url = DEFAULT_SHOW_URL - - # The show's global unique identifier - self.uuid = str(uuid.uuid4()) - - # Get current datetime object in UTC timezone - now = datetime.datetime.now(pytz.timezone("UTC")) - - # The show's start time, initially set to now - self.starttime = now - - # The show's end time, initially set to to now - self.endtime = now + self.uuid = str(uuid.uuid4()) #: The show's global unique identifier def set_name(self, name): - # The name of the show + """Set the show's name.""" self.name = name def set_url(self, url): diff --git a/requirements.txt b/requirements.txt index cfcd0dbd..b2cd4b4c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,4 +3,5 @@ pytz==2021.3 isodate==0.6.1 pylast==4.4.0 lxml==4.7.1 +nowplaypadgen==0.1.1 requests==2.26.0 diff --git a/tests/test_show.py b/tests/test_show.py index e3e4a656..ba6c5887 100644 --- a/tests/test_show.py +++ b/tests/test_show.py @@ -6,12 +6,13 @@ import pytz from nowplaying.show.show import DEFAULT_SHOW_URL, Show, ShowError +from nowplaypadgen.show import Show as PadGenShow def test_init(): """Test :class:`Show`'s :meth:`.__init__` method.""" show = Show() - assert show.starttime == show.endtime + assert isinstance(show, PadGenShow) def test_name(): diff --git a/tests/test_track_observer_tickertrack.py b/tests/test_track_observer_tickertrack.py index 0395eee2..e24a3690 100644 --- a/tests/test_track_observer_tickertrack.py +++ b/tests/test_track_observer_tickertrack.py @@ -1,8 +1,10 @@ """Tests for :class:`observer.TickerTrackObserver`.""" import os +from datetime import datetime, timedelta import pytest +import pytz from nowplaying.track import observer @@ -27,6 +29,10 @@ def test_track_started(track_factory, show_factory): track = track_factory() track.show = show_factory() + now = datetime.now(pytz.timezone("UTC")) + track.show.starttime = now + track.show.endtime = now + timedelta(hours=1) + ticker_track_observer = observer.TickerTrackObserver( ticker_file_path="/tmp/track_started.xml" )