Exemplo n.º 1
0
 def test_from_script_calls(self, Popen, settings):
     settings.env = {}
     assert Command.from_raw_script(
         ['apt-get', 'search', 'vim']) == Command(
         'apt-get search vim', 'stdout', 'stderr')
     Popen.assert_called_once_with('apt-get search vim',
                                   shell=True,
                                   stdout=PIPE,
                                   stderr=PIPE,
                                   env={})
Exemplo n.º 2
0
def test_match(tar_error, filename, script, fixed):
    tar_error(filename)
    assert match(Command(script=script.format(filename)))
Exemplo n.º 3
0
def test_match(script, stderr):
    assert match(Command(script, stderr=stderr), None)
def test_get_new_comman(script, result):
    new_command = get_new_command(
        Command(script, stderr=stderr.format('wlan0')))
    assert new_command == result
def test_get_new_command(pip_unknown_cmd):
    assert get_new_command(Command('pip instatl',
                                   stderr=pip_unknown_cmd)) == 'pip install'
Exemplo n.º 6
0
import pytest
from theoops.rules.dry import match, get_new_command
from tests.utils import Command


@pytest.mark.parametrize('command', [
    Command(script='cd cd foo'),
    Command(script='git git push origin/master')])
def test_match(command):
    assert match(command)


@pytest.mark.parametrize('command, new_command', [
    (Command('cd cd foo'), 'cd foo'),
    (Command('git git push origin/master'), 'git push origin/master')])
def test_get_new_command(command, new_command):
    assert get_new_command(command) == new_command
Exemplo n.º 7
0
def test_match(script, file):
    assert match(Command(script, stderr=stderr(file)))
Exemplo n.º 8
0
def test_not_match(script):
    assert not match(Command(script=script, stderr=''))
Exemplo n.º 9
0
def test_get_new_command(is_not_task):
    assert get_new_command(Command(script='lein rpl --help', stderr=is_not_task)) \
           == ['lein repl --help', 'lein jar --help']
Exemplo n.º 10
0
def test_match(is_not_task):
    assert match(Command(script='lein rpl', stderr=is_not_task))
    assert not match(Command(script='ls', stderr=is_not_task))
Exemplo n.º 11
0
def test_get_new_command(script, result):
    assert get_new_command(Command(script, stdout)) == result
Exemplo n.º 12
0
def test_not_match(script, stdout):
    assert not match(Command(script, stdout))
Exemplo n.º 13
0
import pytest
from thefuck.rules.mvn_unknown_lifecycle_phase import match, get_new_command
from tests.utils import Command


@pytest.mark.parametrize('command', [
    Command(
        script='mvn cle',
        stdout=
        '[ERROR] Unknown lifecycle phase "cle". You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-clean, clean, post-clean, pre-site, site, post-site, site-deploy. -> [Help 1]'
    )
])
def test_match(command):
    assert match(command, None)


@pytest.mark.parametrize('command', [
    Command(script='mvn clean',
            stdout="""
[INFO] Scanning for projects...[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building test 0.2
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ test ---
[INFO] Deleting /home/mlk/code/test/target
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.477s
[INFO] Finished at: Wed Aug 26 13:05:47 BST 2015
Exemplo n.º 14
0
import pytest
from theoops.rules.python_execute import match, get_new_command
from tests.utils import Command


@pytest.mark.parametrize(
    'command', [Command(script='python foo'),
                Command(script='python bar')])
def test_match(command):
    assert match(command)


@pytest.mark.parametrize('command, new_command',
                         [(Command('python foo'), 'python foo.py'),
                          (Command('python bar'), 'python bar.py')])
def test_get_new_command(command, new_command):
    assert get_new_command(command) == new_command
Exemplo n.º 15
0
def test_get_new_command(tar_error, filename, script, fixed):
    tar_error(filename)
    assert get_new_command(
        Command(script=script.format(filename))) == fixed.format(filename)
Exemplo n.º 16
0
def test_match(stderr, stdout):
    assert match(Command(stderr=stderr, stdout=stdout))
Exemplo n.º 17
0
def test_not_match():
    assert not match(Command())
    assert not match(Command(script='sudo ls', stderr='Permission denied'))
Exemplo n.º 18
0
def test_get_new_command(stderr, new_command, script, formula):
    assert get_new_command(Command(script=script,
                                   stderr=stderr)) == new_command
Exemplo n.º 19
0
def test_get_new_command(before, after):
    assert get_new_command(Command(before)) == after
Exemplo n.º 20
0
def test_get_new_command(script, stderr, result):
    assert get_new_command(Command(script, stderr=stderr)) == result
Exemplo n.º 21
0
def test_match(git_not_command, git_command, git_not_command_one_of_this):
    assert match(Command('git brnch', stderr=git_not_command), None)
    assert match(Command('git st', stderr=git_not_command_one_of_this), None)
    assert not match(Command('ls brnch', stderr=git_not_command), None)
    assert not match(Command('git branch', stderr=git_command), None)
Exemplo n.º 22
0
def test_match(pip_unknown_cmd, pip_unknown_cmd_without_recommend):
    assert match(Command('pip instatl', stderr=pip_unknown_cmd))
    assert not match(Command('pip i',
                             stderr=pip_unknown_cmd_without_recommend))
Exemplo n.º 23
0
def test_get_new_command(stderr):
    assert get_new_command(Command('git push', stderr=stderr))\
        == "git push --set-upstream origin master"
    assert get_new_command(Command('git push --quiet', stderr=stderr))\
        == "git push --set-upstream origin master --quiet"
def test_not_match(script, stderr):
    assert not match(Command(script, stderr=stderr))
Exemplo n.º 25
0
def test_match(stderr):
    assert match(Command('git push', stderr=stderr))
    assert match(Command('git push master', stderr=stderr))
    assert not match(Command('git push master'))
    assert not match(Command('ls', stderr=stderr))
Exemplo n.º 26
0
def test_get_new_command():
    assert get_new_command(Command(script='cp dir'), None) == 'cp -a dir'
Exemplo n.º 27
0
def test_get_new_command(script, stdout, new_command):
    assert get_new_command(Command(script=script,
                                   stdout=stdout)) == new_command
Exemplo n.º 28
0
def test_get_new_command():
    """ Replace the Alt+Space character by a simple space """
    assert get_new_command(Command(u'ps -ef | grep foo'))\
           == 'ps -ef | grep foo'
Exemplo n.º 29
0
def test_match(script, stdout):
    assert match(Command(script=script, stdout=stdout))
Exemplo n.º 30
0
def test_side_effect(tar_error, filename, script, fixed):
    tar_error(filename)
    side_effect(Command(script=script.format(filename)), None)
    assert set(os.listdir('.')) == {filename, 'd'}
Exemplo n.º 31
0
def test_match(stderr, script):
    assert match(Command(script=script, stderr=stderr))
Exemplo n.º 32
0
 def test_from_script(self, script, result):
     if result:
         assert Command.from_raw_script(script).script == result
     else:
         with pytest.raises(EmptyCommand):
             Command.from_raw_script(script)
Exemplo n.º 33
0
 def test_from_script_calls(self, Popen, settings):
     settings.env = {}
     assert Command.from_raw_script(["apt-get", "search", "vim"]) == Command(
         "apt-get search vim", "stdout", "stderr"
     )
     Popen.assert_called_once_with("apt-get search vim", shell=True, stdout=PIPE, stderr=PIPE, env={})