Exemplo n.º 1
0
def test_run_error_correct_end_column(magic):
    endpoint = magic()
    d = Diagnostics(endpoint=endpoint)
    ws = magic()
    doc = Document(uri=".my.uri.", text="a = 1\nb=car")
    d.run(ws, doc)
    endpoint.notify.assert_called_with(
        "textDocument/publishDiagnostics",
        {
            "uri":
            doc.uri,
            "diagnostics": [{
                "range": {
                    "start": {
                        "line": 1,
                        "character": 2
                    },
                    "end": {
                        "line": 1,
                        "character": 5
                    },
                },
                "message": "E0101: Variable `car` has not been defined.",
                "severity": DiagnosticSeverity.Error,
            }],
        },
    )
Exemplo n.º 2
0
def test_run_error(magic):
    endpoint = magic()
    d = Diagnostics(endpoint=endpoint)
    ws = magic()
    doc = Document(uri='.my.uri.', text='a = foo')
    d.run(ws, doc)
    endpoint.notify.assert_called_with(
        'textDocument/publishDiagnostics', {
            'uri':
            doc.uri,
            'diagnostics': [{
                'range': {
                    'start': {
                        'line': 1,
                        'character': 5
                    },
                    'end': {
                        'line': 1,
                        'character': 8
                    },
                },
                'message': 'E0101: Variable `foo` has not been defined.',
                'severity': DiagnosticSeverity.Error
            }]
        })
Exemplo n.º 3
0
def test_run_error_correct_column(magic):
    endpoint = magic()
    d = Diagnostics(endpoint=endpoint)
    ws = magic()
    doc = Document(uri=".my.uri.", text="a = 1\nb=$")
    d.run(ws, doc)
    endpoint.notify.assert_called_with(
        "textDocument/publishDiagnostics",
        {
            "uri":
            doc.uri,
            "diagnostics": [{
                "range": {
                    "start": {
                        "line": 1,
                        "character": 2
                    },
                    "end": {
                        "line": 1,
                        "character": 3
                    },
                },
                "message": "E0041: `$` is not allowed here",
                "severity": DiagnosticSeverity.Error,
            }],
        },
    )
Exemplo n.º 4
0
def test_run_error_issue_192(magic):
    endpoint = magic()
    d = Diagnostics(endpoint=endpoint)
    ws = magic()
    doc = Document(
        uri=".my.uri.",
        text=
        'when zoom events RecordingCompleted as recording\n  transcript=""',
    )
    d.run(ws, doc)
    endpoint.notify.assert_called_with(
        "textDocument/publishDiagnostics",
        {
            "uri":
            doc.uri,
            "diagnostics": [{
                "range": {
                    "start": {
                        "line": 0,
                        "character": 0
                    },
                    "end": {
                        "line": 0,
                        "character": 47
                    },
                },
                "message": "E0139: Service `zoom` does not exist on the hub.",
                "severity": DiagnosticSeverity.Error,
            }],
        },
    )
Exemplo n.º 5
0
def test_run_error_correct_no_column(magic):
    endpoint = magic()
    d = Diagnostics(endpoint=endpoint)
    ws = magic()
    doc = Document(uri=".my.uri.", text='function foo\n  a = 1\nb="{foo()}"')
    d.run(ws, doc)
    endpoint.notify.assert_called_with(
        "textDocument/publishDiagnostics",
        {
            "uri":
            doc.uri,
            "diagnostics": [{
                "range": {
                    "start": {
                        "line": 2,
                        "character": 0
                    },
                    "end": {
                        "line": 2,
                        "character": 10
                    },
                },
                "message":
                "E0126: Type casting not supported from `none` to `string`.",
                "severity": DiagnosticSeverity.Error,
            }],
        },
    )
Exemplo n.º 6
0
def test_run_no_error(magic):
    endpoint = magic()
    d = Diagnostics(endpoint=endpoint)
    ws = magic()
    doc = Document(uri='.my.uri.', text='a = 0')
    d.run(ws, doc)
    endpoint.notify.assert_called_with('textDocument/publishDiagnostics', {
        'uri': doc.uri,
        'diagnostics': [],
    })
Exemplo n.º 7
0
def test_run_no_error(magic):
    endpoint = magic()
    d = Diagnostics(endpoint=endpoint)
    ws = magic()
    doc = Document(uri=".my.uri.", text="a = 0")
    d.run(ws, doc)
    endpoint.notify.assert_called_with("textDocument/publishDiagnostics", {
        "uri": doc.uri,
        "diagnostics": [],
    })
Exemplo n.º 8
0
def test_run_empty(magic, patch):
    endpoint = magic()
    patch.object(Diagnostics, "to_error")
    patch.object(Api, "loads")
    Api.loads.errors.return_value = []
    d = Diagnostics(endpoint=endpoint)
    doc = Document(uri=".my.uri.", text="a = 0")
    d.run(ws=magic(), doc=doc)
    endpoint.notify.assert_called_with("textDocument/publishDiagnostics", {
        "uri": doc.uri,
        "diagnostics": [],
    })
Exemplo n.º 9
0
def test_run_empty(magic, patch):
    endpoint = magic()
    patch.object(Diagnostics, 'to_error')
    patch.object(Api, 'loads')
    Api.loads.errors.return_value = []
    d = Diagnostics(endpoint=endpoint)
    doc = Document(uri='.my.uri.', text='a = 0')
    d.run(ws=magic(), doc=doc)
    endpoint.notify.assert_called_with('textDocument/publishDiagnostics', {
        'uri': doc.uri,
        'diagnostics': [],
    })
Exemplo n.º 10
0
def test_run_story_error_internal(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_not_called()
    endpoint.notify.assert_called_with("textDocument/publishDiagnostics", {
        "uri": doc.uri,
        "diagnostics": [],
    })
Exemplo n.º 11
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()],
    })