Skip to content

Commit

Permalink
update test
Browse files Browse the repository at this point in the history
  • Loading branch information
youben11 committed Oct 29, 2019
1 parent f54910d commit c73dedf
Showing 1 changed file with 31 additions and 31 deletions.
62 changes: 31 additions & 31 deletions test/plugins/test_importmagic_lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

DOC_URI = uris.from_fs_path(__file__)
DOC = """
files = listdir()
print(files)
time.sleep(10)
print("test")
"""


Expand All @@ -28,41 +28,41 @@ def test_importmagic_lint():
diags = importmagic_lint.pyls_lint(doc)
unres_symbol = [d for d in diags if d['source'] == 'importmagic'][0]

assert unres_symbol['message'] == "Unresolved import 'listdir'"
assert unres_symbol['range']['start'] == {'line': 1, 'character': 8}
assert unres_symbol['range']['end'] == {'line': 1, 'character': 15}
assert unres_symbol['message'] == "Unresolved import 'time.sleep'"
assert unres_symbol['range']['start'] == {'line': 1, 'character': 0}
assert unres_symbol['range']['end'] == {'line': 1, 'character': 10}
assert unres_symbol['severity'] == lsp.DiagnosticSeverity.Hint

finally:
os.remove(name)


# def test_importmagic_actions(config):
# context = {
# 'diagnostics': [
# {
# 'range':
# {
# 'start': {'line': 1, 'character': 8},
# 'end': {'line': 1, 'character': 15}
# },
# 'message': "Unresolved import 'listdir'",
# 'severity': 4,
# 'source': 'importmagic'
# }
# ]
# }
def test_importmagic_actions(config):
context = {
'diagnostics': [
{
'range':
{
'start': {'line': 1, 'character': 0},
'end': {'line': 1, 'character': 10}
},
'message': "Unresolved import 'time.sleep'",
'severity': lsp.DiagnosticSeverity.Hint,
'source': importmagic_lint.SOURCE
}
]
}

# try:
# name, doc = temp_document(DOC)
# actions = importmagic_lint.pyls_code_actions(config, doc, context)
# action = [a for a in actions if a['title'] == 'Import "listdir" from "os"'][0]
# arguments = action['arguments']
try:
name, doc = temp_document(DOC)
actions = importmagic_lint.pyls_code_actions(config, doc, context)
action = [a for a in actions if a['title'] == 'Import "time"'][0]
arguments = action['arguments']

# assert action['command'] == 'importmagic.addimport'
# assert arguments['startLine'] == 1
# assert arguments['endLine'] == 1
# assert arguments['newText'] == 'from os import listdir\n\n\n'
assert action['command'] == importmagic_lint.ADD_IMPORT_COMMAND
assert arguments['startLine'] == 1
assert arguments['endLine'] == 1
assert arguments['newText'] == 'import time\n\n\n'

# finally:
# os.remove(name)
finally:
os.remove(name)

0 comments on commit c73dedf

Please sign in to comment.