Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_episode_init():
myfeed = Feed(file=my_dir + "/feeds/valid_basic.xml")
myepisode = Episode(myfeed,
title=title,
description=description,
link=link,
pubdate=pubdate,
copyright=copyright,
enclosure=enclosure)
assert isinstance(myepisode, Episode)
feed = Feed(url="feed url",
title="feed title",
description="feed description",
link="feed link",
last_build_date="feed last_build_date",
copyright="feed copyright",
episodes=[])
episode1 = Episode(feed,
title="episode1 title",
description="episode1 description",
link="episode1 link",
pubdate="episode1 pubdate",
copyright="episode1 copyright",
enclosure="episode1 enclosure")
episode2 = Episode(feed,
title="episode2 title",
description="episode2 description",
link="episode2 link",
pubdate="episode2 pubdate",
copyright="episode2 copyright",
enclosure="episode2 enclosure")
display.display()
display.database.replace_feed(feed)
display.database.replace_episodes(feed, [episode1, episode2])
perspective._feed_menu.update_items(None)
perspective._episode_menu.update_items(feed)
perspective._active_window = 0
perspective._create_player_from_selected()
assert display.queue.length == 2
display.queue.clear()
assert display.queue.length == 0
def test_perspective_primary_draw_metadata(display):
perspective = get_primary_perspective(display)
feed = Feed(url="feed url",
title="feed title",
description="feed description",
link="feed link",
last_build_date="feed last_build_date",
copyright="feed copyright",
episodes=[])
episode = Episode(feed,
title="episode title",
description="episode description",
link="episode link",
pubdate="episode pubdate",
copyright="episode copyright",
enclosure="episode enclosure")
display.database.replace_feed(feed)
display.database.replace_episode(feed, episode)
perspective._draw_metadata(perspective._metadata_window)
perspective._draw_metadata(perspective._metadata_window)
import os
from unittest import mock
import pytest
import castero.config
from castero.config import Config
from castero.episode import Episode
from castero.feed import Feed
from castero.player import Player, PlayerDependencyError
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")
SomePlayer = mock.MagicMock()
available_players = {
"someplayer": SomePlayer
}
@pytest.fixture(autouse=True)
def restore_config_data():
yield
Config.data = castero.config._Config().data
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_perspective_primary_create_player(display):
perspective = get_primary_perspective(display)
feed = Feed(url="feed url",
title="feed title",
description="feed description",
link="feed link",
last_build_date="feed last_build_date",
copyright="feed copyright",
episodes=[])
episode1 = Episode(feed,
title="episode1 title",
description="episode1 description",
link="episode1 link",
pubdate="episode1 pubdate",
copyright="episode1 copyright",
enclosure="episode1 enclosure")
episode2 = Episode(feed,
title="episode2 title",
description="episode2 description",
link="episode2 link",
pubdate="episode2 pubdate",
copyright="episode2 copyright",
enclosure="episode2 enclosure")
display.display()
display.database.replace_feed(feed)
display.database.replace_episodes(feed, [episode1, episode2])
def add(self, episode) -> None:
"""Adds an episode to the end of the queue.
"""
assert isinstance(episode, Episode)
if episode not in self._episodes:
self._episodes.append(episode)
def episodes(self, feed: Feed) -> List[Episode]:
"""Retrieve all episodes for a feed.
Args:
feed: the Feed to retrieve episodes of
Returns:
List[Episode]: all Episode's of the given Feed in the database
"""
cursor = self._conn.cursor()
cursor.execute(self.SQL_EPISODES_BY_FEED, (feed.key,))
episodes = []
for row in cursor.fetchall():
episodes.append(Episode(
feed,
ep_id=row[0],
title=row[1],
description=row[2],
link=row[3],
pubdate=row[4],
copyright=row[5],
enclosure=row[6],
played=row[7]
))
return episodes
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']
# if we were unable to find an enclosure for this episode,
# don't add it
if not item_enclosure_str:
continue
episodes.append(
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
)
)
return episodes
def __init__(self, title, path, episode) -> None:
"""
Args:
title: the title of the media (usually an episode title)
path: a URL or file-path of a media file (usually an audio file)
episode: the Episode which this is a player for
"""
assert isinstance(title, str) and title != ""
assert isinstance(path, str) and path != ""
assert isinstance(episode, Episode) and episode is not None
self._title = title
self._path = path
self._episode = episode
self._media = None
self._player = None
self._duration = -1 # in milliseconds
self._state = 0 # 0=stopped, 1=playing, 2=paused