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_database_default(prevent_modification):
mydatabase = Database()
assert isinstance(mydatabase, Database)
def test_database_add_episode(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)
episodes = myfeed.parse_episodes()
mydatabase.replace_feed(myfeed)
assert len(mydatabase.episodes(myfeed)) == 0
mydatabase.replace_episode(myfeed, episodes[0])
assert len(mydatabase.episodes(myfeed)) == 1
def test_database_reload(prevent_modification, display):
mydatabase = Database()
myfeed_path = my_dir + "/feeds/valid_basic.xml"
myfeed = Feed(file=myfeed_path)
real_title = myfeed.title
myfeed._title = "fake title"
mydatabase.replace_feed(myfeed)
display.change_status = mock.MagicMock(name="change_status")
mydatabase.reload(display)
assert display.change_status.call_count == 2
assert mydatabase.feeds()[0].title == real_title
def test_database_episode_id(prevent_modification):
copyfile(my_dir + "/datafiles/database_example1.db", Database.PATH)
mydatabase = Database()
episode = mydatabase.episode(1)
assert episode.ep_id == 1
assert episode.title == "episode title"
def test_database_replace_episode(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)
episodes = myfeed.parse_episodes()
mydatabase.replace_feed(myfeed)
mydatabase.replace_episode(myfeed, episodes[0])
assert len(mydatabase.episodes(myfeed)) == 1
episode = mydatabase.episodes(myfeed)[0]
mydatabase.replace_episode(myfeed, episode)
assert len(mydatabase.episodes(myfeed)) == 1
def test_database_add_episodes(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)
episodes = myfeed.parse_episodes()
mydatabase.replace_feed(myfeed)
assert len(mydatabase.episodes(myfeed)) == 0
mydatabase.replace_episodes(myfeed, episodes)
assert len(mydatabase.episodes(myfeed)) == len(episodes)
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_database_from_json(prevent_modification):
copyfile(my_dir + "/datafiles/feeds_working", Database.OLD_PATH)
mydatabase = Database()
feeds = mydatabase.feeds()
assert len(feeds) == 2
# we don't technically make any assumptions about the order of the feeds
if feeds[0].key != "feed key":
feeds.reverse()
assert feeds[0].key == "feed key"
assert feeds[0].title == "feed title"
assert feeds[0].description == "feed description"
assert feeds[0].link == "feed link"
assert feeds[0].last_build_date == "feed last_build_date"
assert feeds[0].copyright == "feed copyright"
episodes0 = mydatabase.episodes(feeds[0])
assert episodes0[0].title == "episode title"
def test_database_feed_episodes(prevent_modification):
copyfile(my_dir + "/datafiles/database_example1.db", Database.PATH)
mydatabase = Database()
feed = mydatabase.feeds()[0]
episodes = mydatabase.episodes(feed)
for episode in episodes:
assert isinstance(episode, Episode)
def test_database_feeds_length(prevent_modification):
copyfile(my_dir + "/datafiles/database_example1.db", Database.PATH)
mydatabase = Database()
assert len(mydatabase.feeds()) == 2