Skip to content

Commit

Permalink
feat: use Show from nowplaypadgen project
Browse files Browse the repository at this point in the history
  • Loading branch information
hairmare committed Dec 26, 2021
1 parent 32ed250 commit d2faacb
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 20 deletions.
26 changes: 7 additions & 19 deletions nowplaying/show/show.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 2 additions & 1 deletion tests/test_show.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@

import pytest
import pytz
from nowplaypadgen.show import Show as PadGenShow

from nowplaying.show.show import DEFAULT_SHOW_URL, Show, ShowError


def test_init():
"""Test :class:`Show`'s :meth:`.__init__` method."""
show = Show()
assert show.starttime == show.endtime
assert isinstance(show, PadGenShow)


def test_name():
Expand Down
6 changes: 6 additions & 0 deletions tests/test_track_observer_tickertrack.py
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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"
)
Expand Down

0 comments on commit d2faacb

Please sign in to comment.