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_perspective_regression_11(display):
perspective = get_primary_perspective(display)
old_ddir = Config["custom_download_dir"]
Config.data["custom_download_dir"] = os.path.join(my_dir, "downloaded")
feed = Feed(file="%s/feeds/valid_basic.xml" % (my_dir))
display.database.replace_feed(feed)
display.database.replace_episodes(feed, feed.parse_episodes())
display.menus_valid = False
display.display()
display.queue.clear()
perspective._active_window = 1
perspective._create_player_from_selected()
assert display.queue[0]._path == os.path.join(my_dir, "downloaded",
"myfeed_title",
"myfeed_item1_title.mp3")
Config.data["custom_download_dir"] = old_ddir
def test_episode_delete(display):
DataFile.DEFAULT_DOWNLOADED_DIR = os.path.join(my_dir, "downloaded")
episode_location = os.path.join(DataFile.DEFAULT_DOWNLOADED_DIR,
"myfeed_title/myfeed_item2_title.mp3")
with open(episode_location, "w") as file:
file.write("temp file for test_episode.test_episode_delete")
myfeed = Feed(file=my_dir + "/feeds/valid_basic.xml")
display.change_status = mock.MagicMock(name="change_status")
episode = myfeed.parse_episodes()[1]
assert episode.downloaded
episode.delete(display=display)
assert display.change_status.call_count == 1
assert not episode.downloaded
DataFile.DEFAULT_DOWNLOADED_DIR = os.path.join(DataFile.DATA_DIR,
"downloaded")
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_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",
def test_feed_validations_no_version():
with pytest.raises(feed.FeedStructureError):
feed.Feed(file=my_dir + "/feeds/broken_no_version.xml")
def test_database_add_feed(prevent_modification):
copyfile(my_dir + "/datafiles/database_example1.db", Database.PATH)
mydatabase = Database()
myfeed_path = my_dir + "/feeds/valid_basic.xml"
myfeed = Feed(file=myfeed_path)
assert len(mydatabase.feeds()) == 2
mydatabase.replace_feed(myfeed)
assert len(mydatabase.feeds()) == 3
def test_episode_playable_local():
DataFile.DEFAULT_DOWNLOADED_DIR = os.path.join(my_dir, "downloaded")
myfeed = Feed(file=my_dir + "/feeds/valid_basic.xml")
episode = myfeed.parse_episodes()[0]
playable = episode.get_playable()
assert episode.downloaded
assert playable == os.path.join(DataFile.DEFAULT_DOWNLOADED_DIR,
"myfeed_title",
"myfeed_item1_title.mp3")
DataFile.DEFAULT_DOWNLOADED_DIR = os.path.join(DataFile.DATA_DIR,
"downloaded")
def test_feed_load_error():
with pytest.raises(feed.FeedLoadError):
feed.Feed(file="notreal")
Args:
display: (optional) the display to write status updates to
"""
total_feeds = len(self.data)
current_feed = 1
for key in self.data:
if display is not None:
display.change_status(
"Reloading feeds (%d/%d)" % (current_feed, total_feeds)
)
# assume urls start with http (change later?)
if key.startswith('http'):
feed = Feed(url=key)
else:
feed = Feed(file=key)
self.data[key] = feed
current_feed += 1
self.write()
if display is not None:
display.change_status("Feeds successfully reloaded")
display.create_menus()
This method automatically calls write() after reloading the feeds.
Args:
display: (optional) the display to write status updates to
"""
total_feeds = len(self.data)
current_feed = 1
for key in self.data:
if display is not None:
display.change_status(
"Reloading feeds (%d/%d)" % (current_feed, total_feeds)
)
# assume urls start with http (change later?)
if key.startswith('http'):
feed = Feed(url=key)
else:
feed = Feed(file=key)
self.data[key] = feed
current_feed += 1
self.write()
if display is not None:
display.change_status("Feeds successfully reloaded")
display.create_menus()