예제 #1
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()
예제 #2
0
def test_app_parse(patch, parser, read_story):
    """
    Ensures App.parse runs Parser.parse
    """
    patch.object(Compiler, 'compile')
    result = App.parse(['test.story'])
    App.read_story.assert_called_with('test.story')
    Parser.__init__.assert_called_with(ebnf_file=None)
    Parser().parse.assert_called_with(App.read_story())
    Compiler.compile.assert_called_with(Parser().parse())
    assert result == {'test.story': Compiler.compile()}
예제 #3
0
def test_app_parse_ebnf_file(patch, parser, read_story):
    patch.object(Compiler, 'compile')
    App.parse(['test.story'], ebnf_file='test.ebnf')
    Parser.__init__.assert_called_with(ebnf_file='test.ebnf')