Exemplo n.º 1
0
def test_to_error_end(magic):
    e = magic()
    e.int_line.return_value = 0
    e.error.column = 10
    e.error.end_column = 42
    d = Diagnostics(endpoint=None)
    assert d.to_error(e) == {
        'range': {
            'start': {'line': 0, 'character': 10},
            'end': {'line': 0, 'character': 42},
        },
        'message': e.short_message(),
        'severity': DiagnosticSeverity.Error
    }
Exemplo n.º 2
0
def test_run_story_error(magic, patch):
    endpoint = magic()
    se = StoryError(None, None)
    patch.init(Story)
    patch.object(Diagnostics, 'to_error')
    patch.object(Api, 'loads')
    Api.loads().errors.return_value = [se]
    d = Diagnostics(endpoint=endpoint)
    doc = Document(uri='.my.uri.', text='a = 0')
    d.run(ws=magic(), doc=doc)
    d.to_error.assert_called_with(se)
    endpoint.notify.assert_called_with('textDocument/publishDiagnostics', {
        'uri': doc.uri,
        'diagnostics': [Diagnostics.to_error()],
    })
Exemplo n.º 3
0
def test_run_story_error(magic, patch):
    endpoint = magic()
    se = StoryError(None, ".story.")
    patch.init(Story)
    patch.object(Diagnostics, "to_error")
    patch.object(Api, "loads")
    Api.loads().errors.return_value = [se]
    d = Diagnostics(endpoint=endpoint)
    doc = Document(uri=".my.uri.", text="a = 0")
    d.run(ws=magic(), doc=doc)
    d.to_error.assert_called_with(se)
    endpoint.notify.assert_called_with(
        "textDocument/publishDiagnostics",
        {
            "uri": doc.uri,
            "diagnostics": [Diagnostics.to_error()],
        },
    )
Exemplo n.º 4
0
def test_to_error_end(magic):
    e = magic()
    e.int_line.return_value = 0
    e.error.column = 10
    e.error.end_column = 42
    d = Diagnostics(endpoint=None)
    assert d.to_error(e) == {
        "range": {
            "start": {
                "line": 0,
                "character": 9
            },
            "end": {
                "line": 0,
                "character": 41
            },
        },
        "message": e.short_message(),
        "severity": DiagnosticSeverity.Error,
    }