Initial upload: ErrorFix CLI with rule engine and pattern matching
Some checks failed
CI / test (push) Failing after 12s
Some checks failed
CI / test (push) Failing after 12s
This commit is contained in:
46
tests/test_cli.py
Normal file
46
tests/test_cli.py
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
import pytest
|
||||||
|
from click.testing import CliRunner
|
||||||
|
from errorfix.cli import cli
|
||||||
|
|
||||||
|
|
||||||
|
class TestCLI:
|
||||||
|
def setup_method(self):
|
||||||
|
self.runner = CliRunner()
|
||||||
|
|
||||||
|
def test_cli_help(self):
|
||||||
|
result = self.runner.invoke(cli, ['--help'])
|
||||||
|
assert result.exit_code == 0
|
||||||
|
assert 'cli' in result.output.lower()
|
||||||
|
|
||||||
|
def test_fix_command_help(self):
|
||||||
|
result = self.runner.invoke(cli, ['fix', '--help'])
|
||||||
|
assert result.exit_code == 0
|
||||||
|
assert 'input' in result.output.lower()
|
||||||
|
|
||||||
|
def test_fix_with_stdin_input(self):
|
||||||
|
result = self.runner.invoke(cli, ['fix', '-i', '-'], input='Unknown error')
|
||||||
|
assert result.exit_code == 0
|
||||||
|
|
||||||
|
def test_fix_with_rule_path(self):
|
||||||
|
result = self.runner.invoke(
|
||||||
|
cli,
|
||||||
|
['fix', '-r', 'rules/python', '-i', '-'],
|
||||||
|
input="NameError: name 'foo' is not defined"
|
||||||
|
)
|
||||||
|
assert result.exit_code == 0
|
||||||
|
|
||||||
|
def test_fix_with_json_output(self):
|
||||||
|
result = self.runner.invoke(
|
||||||
|
cli,
|
||||||
|
['fix', '-f', 'json', '-i', '-'],
|
||||||
|
input='Unknown error'
|
||||||
|
)
|
||||||
|
assert result.exit_code == 0
|
||||||
|
|
||||||
|
def test_plugins_command(self):
|
||||||
|
result = self.runner.invoke(cli, ['plugins'])
|
||||||
|
assert result.exit_code == 0
|
||||||
|
|
||||||
|
def test_check_command(self):
|
||||||
|
result = self.runner.invoke(cli, ['check', '-r', 'rules/python'])
|
||||||
|
assert result.exit_code == 0
|
||||||
Reference in New Issue
Block a user