Beispiel #1
0
def test_app_get_stories_directory(mocker):
    """
    Ensures App.get_stories returns stories in a directory
    """
    mocker.patch.object(os.path, 'isdir')
    mocker.patch.object(os,
                        'walk',
                        return_value=[('root', [], ['one.story', 'two'])])
    assert App.get_stories('stories') == ['root/one.story']
Beispiel #2
0
def test_app_compile(patch):
    patch.object(json, 'dumps')
    patch.many(App, ['get_stories', 'parse', 'services'])
    result = App.compile('path')
    App.get_stories.assert_called_with('path')
    App.parse.assert_called_with(App.get_stories(), ebnf_file=None)
    App.services.assert_called_with(App.parse())
    dictionary = {'stories': App.parse(), 'services': App.services()}
    json.dumps.assert_called_with(dictionary, indent=2)
    assert result == json.dumps()
Beispiel #3
0
def test_app_get_stories(mocker):
    """
    Ensures App.get_stories returns the original path if it's not a directory
    """
    mocker.patch.object(os.path, 'isdir', return_value=False)
    assert App.get_stories('stories') == ['stories']
Beispiel #4
0
def test_app_compile_ebnf_file(patch):
    patch.object(json, 'dumps')
    patch.many(App, ['get_stories', 'parse', 'services'])
    App.compile('path', ebnf_file='test.ebnf')
    App.parse.assert_called_with(App.get_stories(), ebnf_file='test.ebnf')