Skip to content
This repository has been archived by the owner on Feb 1, 2019. It is now read-only.

Commit

Permalink
tests: Add test cases for diagnostic
Browse files Browse the repository at this point in the history
  • Loading branch information
gaocegege committed Feb 11, 2017
1 parent a99350f commit b82cca6
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ before_install:
sleep 3;
fi

before_script:
# nltk 3.2.2 dropped support for Python 3.3
- >
if [[ "$TRAVIS_PYTHON_VERSION" != "3.3" ]]; then
python -m nltk.downloader punkt maxent_treebank_pos_tagger averaged_perceptron_tagger
fi
install:
# beheve is a dev dependeny, so not in requirements.txt.
- pip install behave
Expand Down
7 changes: 7 additions & 0 deletions tests/server.features/diagnostic.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Feature: diagnostic module
diagnostic is a module of language-server.

Scenario: Test output_to_diagnostics
Given the output with errors by coala
When I pass the parameters to output_to_diagnostics
Then it should return output in vscode format
35 changes: 35 additions & 0 deletions tests/server.features/steps/diagnostic_steps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# -*- coding: UTF-8 -*-

# @mark.steps
# ----------------------------------------------------------------------------
# STEPS:
# ----------------------------------------------------------------------------
import os
from behave import given, when, then
from coala_langserver.diagnostic import output_to_diagnostics
from coala_langserver.coalashim import run_coala_with_specific_file


@given('the output with errors by coala')
def step_impl(context):
context.dir = os.path.abspath(
os.path.join(
os.path.dirname(os.path.abspath(__file__)),
os.pardir,
os.pardir,
'resources'
)
)
context.path = os.path.join(context.dir, 'unqualified.py')

context.output = run_coala_with_specific_file(context.dir, context.path)


@when('I pass the parameters to output_to_diagnostics')
def step_impl(context):
context.message = output_to_diagnostics(context.output)


@then('it should return output in vscode format')
def step_impl(context):
assert len(context.message) is not 0

0 comments on commit b82cca6

Please sign in to comment.