Esempio n. 1
0
def test_story_read(patch):
    """
    Ensures Story.read can read a story
    """
    patch.object(StoryModule, 'bom_open')
    Story.read('hello.story')
    StoryModule.bom_open.assert_called_with('hello.story', 'r')
Esempio n. 2
0
def test_story_from_file(patch):
    patch.init(Story)
    patch.object(Story, 'read')
    result = Story.from_file('hello.story', features=None)
    Story.read.assert_called_with('hello.story')
    Story.__init__.assert_called_with(Story.read(), None, path='hello.story')
    assert isinstance(result, Story)
Esempio n. 3
0
def test_story_read(patch):
    """
    Ensures Story.read can read a story
    """
    patch.object(io, 'open')
    result = Story.read('hello.story')
    io.open.assert_called_with('hello.story', 'r')
    assert result == io.open().__enter__().read()
Esempio n. 4
0
def test_bundle_load_story_not_read(patch, bundle):
    """
    Ensures Bundle.load_story reads a story before loading it
    """
    patch.init(Story)
    patch.object(Story, 'read')
    bundle.story_files = {}
    bundle.load_story('one.story')
    Story.read.assert_called_with('one.story')
    assert bundle.story_files['one.story'] == Story.read()
Esempio n. 5
0
def test_story_read_not_found(patch, capsys):
    patch.object(io, 'open', side_effect=FileNotFoundError)
    patch.object(os, 'path')
    with raises(StoryError) as e:
        Story.read('whatever')
    assert 'E0047: File `whatever` not found at ' in e.value.short_message()