Beispiel #1
0
def test_cli_parse_json(runner, echo, app, option):
    """
    Ensures --json outputs json
    """
    runner.invoke(Cli.parse, ['/path', option])
    App.compile.assert_called_with('/path', ebnf_file=None)
    click.echo.assert_called_with(App.compile())
Beispiel #2
0
def test_app_compile(patch):
    patch.object(json, 'dumps')
    patch.init(Bundle)
    patch.object(Bundle, 'bundle')
    result = App.compile('path')
    Bundle.__init__.assert_called_with('path')
    Bundle.bundle.assert_called_with(ebnf_file=None, debug=False)
    json.dumps.assert_called_with(Bundle.bundle(), indent=2)
    assert result == json.dumps()
Beispiel #3
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 #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')
Beispiel #5
0
def test_app_compile_debug(patch):
    patch.object(json, 'dumps')
    patch.init(Bundle)
    patch.object(Bundle, 'bundle')
    App.compile('path', debug='debug')
    Bundle.bundle.assert_called_with(ebnf_file=None, debug='debug')
Beispiel #6
0
def test_app_compile_ebnf_file(patch):
    patch.object(json, 'dumps')
    patch.init(Bundle)
    patch.object(Bundle, 'bundle')
    App.compile('path', ebnf_file='ebnf')
    Bundle.bundle.assert_called_with(ebnf_file='ebnf', debug=False)