def test_episode_str_title(): myfeed = Feed(file=my_dir + "/feeds/valid_basic.xml") myepisode = Episode(myfeed, title=title) assert str(myepisode) == title
def test_episode_str_description(): myfeed = Feed(file=my_dir + "/feeds/valid_basic.xml") myepisode = Episode(myfeed, description=description) assert str(myepisode) == description
def test_episode_only_title(): myfeed = Feed(file=my_dir + "/feeds/valid_basic.xml") myepisode = Episode(myfeed, title=title) assert isinstance(myepisode, Episode)
def test_episode_only_description(): myfeed = Feed(file=my_dir + "/feeds/valid_basic.xml") myepisode = Episode(myfeed, description=description) assert isinstance(myepisode, Episode)
def test_episode_missing_property_copyright(): myfeed = Feed(file=my_dir + "/feeds/valid_basic.xml") myepisode = Episode(myfeed, title=title) assert myepisode.copyright == "No copyright specified."
def test_episode_missing_property_enclosure(): myfeed = Feed(file=my_dir + "/feeds/valid_basic.xml") myepisode = Episode(myfeed, title=title) assert myepisode.enclosure == "Enclosure not available."
def test_episode_missing_property_link(): myfeed = Feed(file=my_dir + "/feeds/valid_basic.xml") myepisode = Episode(myfeed, title=title) assert myepisode.link == "Link not available."
def test_episode_missing_property_pubdate(): myfeed = Feed(file=my_dir + "/feeds/valid_basic.xml") myepisode = Episode(myfeed, title=title) assert myepisode.pubdate == "Publish date not available."
def test_episode_missing_property_description(): myfeed = Feed(file=my_dir + "/feeds/valid_basic.xml") myepisode = Episode(myfeed, title=title) assert myepisode.description == "Description not available."
def test_episode_missing_property_title(): myfeed = Feed(file=my_dir + "/feeds/valid_basic.xml") myepisode = Episode(myfeed, description=description) assert myepisode.title == "Title not available."
import os from unittest import mock from castero.config import Config from castero.episode import Episode from castero.feed import Feed from castero.player import Player from castero.queue import Queue my_dir = os.path.dirname(os.path.realpath(__file__)) feed = Feed(file=my_dir + "/feeds/valid_basic.xml") episode = Episode(feed, title="episode title", description="episode description", link="episode link", pubdate="episode pubdate", copyright="episode copyright", enclosure="episode enclosure") player1 = Player("MLK Dream", my_dir + "/media/MLK_Dream_10s.mp3", episode) player2 = Player("MLK Dream", my_dir + "/media/MLK_Dream_10s.mp3", episode) player3 = Player("MLK Dream", my_dir + "/media/MLK_Dream_10s.mp3", episode) queue = Queue(mock.MagicMock()) queue.add(player1) queue.add(player2) def get_queue_perspective(display): """Retrieve the Queue perspective. Args:
import os from unittest import mock from castero.downloadqueue import DownloadQueue from castero.episode import Episode from castero.feed import Feed my_dir = os.path.dirname(os.path.realpath(__file__)) feed = Feed(file=my_dir + "/feeds/valid_enclosures.xml") episode1 = Episode(feed=feed, title="episode1 title") episode2 = Episode(feed=feed, title="episode2 title") def test_downloadqueue_init(): mydownloadqueue = DownloadQueue() assert isinstance(mydownloadqueue, DownloadQueue) def test_downloadqueue_add(): mydownloadqueue = DownloadQueue() assert mydownloadqueue.length == 0 mydownloadqueue.add(episode1) assert mydownloadqueue.length == 1 mydownloadqueue.add(episode1) assert mydownloadqueue.length == 1 mydownloadqueue.add(episode2) assert mydownloadqueue.length == 2 def test_downloadqueue_start():
def _process_feed(self): """Processes the RSS feed to set metadata and create episodes. It is required that _validate_feed be run prior to running this method. """ assert self._validated channel = list(self._tree)[0] self._title = channel.find('title').text self._description = channel.find('description').text self._link = channel.find('link').text last_build_date_tag = channel.find('lastBuildDate') copyright_tag = channel.find('copyright') if last_build_date_tag is not None: self._last_build_date = last_build_date_tag.text if copyright_tag is not None: self._copyright = copyright_tag.text # process items into episodes for item in channel.findall('item'): item_title = item.find('title') item_description = item.find('description') item_link = item.find('link') item_pubdate = item.find('pubDate') item_copyright = item.find('copyright') item_enclosure = item.find('enclosure') item_title_str = None item_description_str = None item_link_str = None item_pubdate_str = None item_copyright_str = None item_enclosure_str = None if item_title is not None: item_title_str = item_title.text if item_description is not None: item_description_str = item_description.text if item_link is not None: item_link_str = item_link.text if item_pubdate is not None: item_pubdate_str = item_pubdate.text if item_copyright is not None: item_copyright_str = item_copyright.text if item_enclosure is not None: if 'url' in item_enclosure.attrib.keys(): item_enclosure_str = item_enclosure.attrib['url'] episode = Episode(self, title=item_title_str, description=item_description_str, link=item_link_str, pubdate=item_pubdate_str, copyright=item_copyright_str, enclosure=item_enclosure_str) self._episodes.append(episode) # restrict number of episodes, if necessary max_episodes = int(Config["max_episodes"]) if max_episodes > -1: self._episodes = self._episodes[:max_episodes]