Beispiel #1
0
def test_delete_story():
    story_id = story_list.save_story("delete book", "delete theme")
    stories = story_list.get_stories()
    found = False
    for story in stories:
        if "delete" in story['book']:
            found = True
    assert found
    story_list.delete_story(story_id)
    stories = story_list.get_stories()
    found = False
    for story in stories:
        if "delete" in story['book']:
            found = True
    assert not found
Beispiel #2
0
def get_story_list():
    stories = story_list.get_stories()
    for story in stories:
        book = story['book']
        theme = story['theme']
    output = template('story_list.tpl', stories=stories)
    return output
Beispiel #3
0
def test_get_story_by_key():
    stories = story_list.get_stories()
    key1 = stories[0]['book'].split(' ')[0]
    assert type(key1) is str
    story = story_list.get_story_by_key(key1)
    assert key1 in story[0]['book']
    assert key1 in story[0]['theme']
Beispiel #4
0
def test_get_stories():
    story_list.save_story("Test book 1", "Test theme 1")
    stories = story_list.get_stories()
    assert type(stories) is list
    for story in stories:
        for item in ['_id', 'book', 'theme']:
            assert type(story[item]) is str
        assert story['book'] == 'Test book 1'
        assert story['theme'] == 'Test theme 1'
Beispiel #5
0
def test_save_story():
    story_list.save_story("save book", "save theme")
    stories = story_list.get_stories()
    assert type(stories) is list
    found = False
    for story in stories:
        assert 'book' in story
        if story['book'] == "save book":
            found = True
    assert found
Beispiel #6
0
def teardown_module():
    stories = story_list.get_stories()
    for story_id in [s['_id'] for s in stories]:
        story_list.delete_story(story_id)
Beispiel #7
0
def setup_module():
    for story_id in [s['_id'] for s in story_list.get_stories()]:
        story_list.delete_story(story_id)
Beispiel #8
0
def test_get_story():
    stories = story_list.get_stories()
    story_id = stories[0]['_id']
    story_get = story_list.get_story(story_id)
    assert stories[0]['book'] == story_get['book']
    assert stories[0]['theme'] == story_get['theme']