How to use the castero.database.Database function in castero

To help you get started, we’ve selected a few castero examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github xgi / castero / tests / test_database.py View on Github external
def test_database_default(prevent_modification):
    mydatabase = Database()
    assert isinstance(mydatabase, Database)
github xgi / castero / tests / test_database.py View on Github external
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
github xgi / castero / tests / test_database.py View on Github external
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
github xgi / castero / tests / test_database.py View on Github external
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"
github xgi / castero / tests / test_database.py View on Github external
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
github xgi / castero / tests / test_database.py View on Github external
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)
github xgi / castero / tests / test_database.py View on Github external
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
github xgi / castero / tests / test_database.py View on Github external
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"
github xgi / castero / tests / test_database.py View on Github external
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)
github xgi / castero / tests / test_database.py View on Github external
def test_database_feeds_length(prevent_modification):
    copyfile(my_dir + "/datafiles/database_example1.db", Database.PATH)
    mydatabase = Database()

    assert len(mydatabase.feeds()) == 2