1
0
mirror of https://github.com/nvbn/thefuck.git synced 2024-10-06 10:51:11 +01:00
thefuck/tests/rules/test_git_not_command.py

58 lines
1.4 KiB
Python
Raw Normal View History

2015-04-08 20:20:11 +01:00
import pytest
from thefuck.rules.git_not_command import match, get_new_command
from thefuck.types import Command
2015-04-08 20:20:11 +01:00
@pytest.fixture
def git_not_command():
return """git: 'brnch' is not a git command. See 'git --help'.
The most similar command is
2015-04-08 20:20:11 +01:00
branch
"""
@pytest.fixture
def git_not_command_one_of_this():
return """git: 'st' is not a git command. See 'git --help'.
The most similar commands are
status
reset
stage
stash
stats
"""
2015-07-08 19:33:30 +01:00
@pytest.fixture
def git_not_command_closest():
return '''git: 'tags' is not a git command. See 'git --help'.
The most similar commands are
\tstage
\ttag
2015-07-08 19:33:30 +01:00
'''
2015-04-08 20:20:11 +01:00
@pytest.fixture
def git_command():
return "* master"
def test_match(git_not_command, git_command, git_not_command_one_of_this):
assert match(Command('git brnch', git_not_command))
assert match(Command('git st', git_not_command_one_of_this))
assert not match(Command('ls brnch', git_not_command))
assert not match(Command('git branch', git_command))
2015-04-08 20:20:11 +01:00
2015-07-08 19:33:30 +01:00
def test_get_new_command(git_not_command, git_not_command_one_of_this,
git_not_command_closest):
assert (get_new_command(Command('git brnch', git_not_command))
== ['git branch'])
assert (get_new_command(Command('git st', git_not_command_one_of_this))
== ['git stats', 'git stash', 'git stage'])
assert (get_new_command(Command('git tags', git_not_command_closest))
== ['git tag', 'git stage'])