Skip to content

Commit

Permalink
test: new functions added and multi suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
pyrrolizin committed Jul 1, 2022
1 parent 076e63a commit 3ae83e3
Showing 1 changed file with 36 additions and 8 deletions.
44 changes: 36 additions & 8 deletions tests/rules/test_brew_install.py
@@ -1,10 +1,20 @@
import pytest
from thefuck.rules.brew_install import match, get_new_command
from thefuck.rules.brew_install import match, get_new_command, get_suggestions
from thefuck.types import Command


@pytest.fixture
def brew_no_available_formula():
def brew_no_available_formula_one():
return '''Warning: No available formula with the name "giss". Did you mean gist?'''


@pytest.fixture
def brew_no_available_formula_two():
return '''Warning: No available formula with the name "elasticserar". Did you mean elasticsearch or elasticsearch@6?'''


@pytest.fixture
def brew_no_available_formula_three():
return '''Warning: No available formula with the name "gitt". Did you mean git, gitg or gist?'''


Expand All @@ -18,20 +28,38 @@ def brew_already_installed():
return '''Warning: git-2.3.5 already installed'''


def test_match(brew_no_available_formula, brew_already_installed,
def test_suggestions():
assert get_suggestions("one") == ['one']
assert get_suggestions("one or two") == ['one', 'two']
assert get_suggestions("one, two or three") == ['one', 'two', 'three']


def test_match(brew_no_available_formula_one, brew_no_available_formula_two,
brew_no_available_formula_three, brew_already_installed,
brew_install_no_argument):
assert match(Command('brew install giss',
brew_no_available_formula_one))
assert match(Command('brew install elasticserar',
brew_no_available_formula_two))
assert match(Command('brew install gitt',
brew_no_available_formula))
brew_no_available_formula_three))
assert not match(Command('brew install git',
brew_already_installed))
assert not match(Command('brew install', brew_install_no_argument))


def test_get_new_command(brew_no_available_formula):
def test_get_new_command(brew_no_available_formula_one, brew_no_available_formula_two,
brew_no_available_formula_three):
assert get_new_command(Command('brew install giss',
brew_no_available_formula_one))\
== ['brew install gist']
assert get_new_command(Command('brew install elasticsear',
brew_no_available_formula_two))\
== ['brew install elasticsearch', 'brew install elasticsearch@6']
assert get_new_command(Command('brew install gitt',
brew_no_available_formula))\
== 'brew install git'
brew_no_available_formula_three))\
== ['brew install git', 'brew install gitg', 'brew install gist']

assert get_new_command(Command('brew install aa',
brew_no_available_formula))\
brew_no_available_formula_one))\
!= 'brew install aha'

0 comments on commit 3ae83e3

Please sign in to comment.