コード例 #1
0
ファイル: app.py プロジェクト: jayvdb/sls
def test_complete_with_line_column(hub):
    """
    Tests that an SLS App can perform completion.
    """
    app = App()
    result = app.complete('.uri.', 'foobar\nhttp foo', line=1, column=1)
    del result[0]['documentation']
    del result[0]['detail']
    result = [{
        'label': 'http',
        'kind': 3,
        'textEdit': {
            'range': {
                'start': {
                    'line': 0,
                    'character': 0
                },
                'end': {
                    'line': 0,
                    'character': 1
                },
            },
            'newText': 'http '
        }
    }]
コード例 #2
0
ファイル: cli.py プロジェクト: wilzbach/storyscript-sls
def test_cli_complete_line_column(patch, runner, echo, app, options, expected):
    """
    Ensures CLI completion with custom line and column works.
    """
    with runner.isolated_filesystem():
        patch.object(json, "dumps")
        text = "foobar"
        with open("my.story", "w") as f:
            f.write(text)
        e = runner.invoke(Cli.main, ["complete", "my.story", *options])
        app.complete.assert_called_with("|completion|", text, **expected)
        json.dumps.assert_called_with(App.complete(), indent=2, sort_keys=True)
        click.echo.assert_called_with(json.dumps())
        assert e.exit_code == 0
コード例 #3
0
ファイル: cli.py プロジェクト: jayvdb/sls
def test_cli_complete_line_column(patch, runner, echo, app, options, expected):
    """
    Ensures CLI completion with custom line and column works.
    """
    patch.object(json, 'dumps')
    with runner.isolated_filesystem():
        text = 'foobar'
        with open('my.story', 'w') as f:
            f.write(text)
        e = runner.invoke(Cli.main, ['complete', 'my.story', *options])
        App.complete.assert_called_with('|completion|', text, **expected)
        json.dumps.assert_called_with(App.complete(), indent=2, sort_keys=True)
        click.echo.assert_called_with(json.dumps())
        assert e.exit_code == 0
コード例 #4
0
ファイル: cli.py プロジェクト: wilzbach/storyscript-sls
def test_cli_complete_hub(patch, runner, echo, app):
    """
    Ensures CLI completion with a custom hub works.
    """
    with runner.isolated_filesystem():
        patch.object(json, "dumps")
        text = "foobar"
        with open("my.story", "w") as f:
            f.write(text)
        with open("my.hub", "w") as f:
            f.write("Hello World!")
        e = runner.invoke(Cli.main, ["--hub=my.hub", "complete", "my.story"])
        app.__init__.assert_called_with(hub_path="my.hub")
        app.complete.assert_called_with("|completion|",
                                        text,
                                        line=None,
                                        column=None)
        json.dumps.assert_called_with(App.complete(), indent=2, sort_keys=True)
        click.echo.assert_called_with(json.dumps())
        assert e.exit_code == 0
コード例 #5
0
ファイル: cli.py プロジェクト: jayvdb/sls
def test_cli_complete_hub(patch, runner, echo, app):
    """
    Ensures CLI completion with a custom hub works.
    """
    patch.object(json, 'dumps')
    with runner.isolated_filesystem():
        text = 'foobar'
        with open('my.story', 'w') as f:
            f.write(text)
        with open('my.hub', 'w') as f:
            f.write('Hello World!')
        e = runner.invoke(Cli.main, ['--hub=my.hub', 'complete', 'my.story'])
        App.__init__.assert_called_with(hub_path='my.hub')
        App.complete.assert_called_with('|completion|',
                                        text,
                                        line=None,
                                        column=None)
        json.dumps.assert_called_with(App.complete(), indent=2, sort_keys=True)
        click.echo.assert_called_with(json.dumps())
        assert e.exit_code == 0
コード例 #6
0
def test_complete_with_line_column(hub):
    """
    Tests that an SLS App can perform completion.
    """
    app = App(hub=hub)
    result = app.complete(".uri.", "foobar\nhttp foo", line=1, column=1)
    del result[0]["documentation"]
    del result[0]["detail"]
    assert result == [
        {
            "insertTextFormat": 1,
            "label": "http",
            "kind": 2,
            "sortText": "40-http",
            "textEdit": {
                "range": {
                    "start": {"line": 1, "character": 0},
                    "end": {"line": 1, "character": 1},
                },
                "newText": "http",
            },
        }
    ]