Ejemplo n.º 1
0
from .app import (run_analysis, get_tools, UnknownTools, Imhotep, NoCommitInfo,
                  run, load_plugins, gen_imhotep, find_config)
from imhotep.main import load_config
from imhotep.testing_utils import fixture_path
from .reporters.printing import PrintingReporter
from .reporters.github import CommitReporter, PRReporter
from .repositories import Repository, ToolsNotFound
from .repomanagers import RepoManager
from .tools import Tool
from .diff_parser import Entry


repo_name = 'justinabrahms/imhotep'

with open(fixture_path('remote_pr.json')) as f:
    remote_json_fixture = json.loads(f.read())


def test_run():
    with mock.patch("subprocess.Popen") as popen:
        run('test')
        popen.assert_called_with(
            ['test'], cwd='.', stdout=mock.ANY, shell=True)


def test_run_known_cwd():
    with mock.patch("subprocess.Popen") as popen:
        run('test', cwd="/known")
        popen.assert_called_with(
            ['test'], cwd='/known', stdout=mock.ANY, shell=True)
Ejemplo n.º 2
0
    run,
    load_plugins,
    gen_imhotep,
    find_config,
)
from imhotep.main import load_config
from imhotep.testing_utils import fixture_path
from .reporters.printing import PrintingReporter
from .reporters.github import CommitReporter, PRReporter
from .repositories import Repository, ToolsNotFound
from .diff_parser import Entry


repo_name = "justinabrahms/imhotep"

with open(fixture_path("remote_pr.json")) as f:
    remote_json_fixture = json.loads(f.read())


def test_run():
    with mock.patch("subprocess.Popen") as popen:
        run("test")
        popen.assert_called_with(["test"], cwd=".", stdout=mock.ANY, shell=True)


def test_run_known_cwd():
    with mock.patch("subprocess.Popen") as popen:
        run("test", cwd="/known")
        popen.assert_called_with(["test"], cwd="/known", stdout=mock.ANY, shell=True)

Ejemplo n.º 3
0
import mock

from .app import (run_analysis, get_tools, UnknownTools, Imhotep, NoCommitInfo,
                  run, load_plugins, gen_imhotep, find_config)
from imhotep.main import load_config
from imhotep.testing_utils import fixture_path
from .reporters.printing import PrintingReporter
from .reporters.github import CommitReporter, PRReporter
from .repositories import Repository, ToolsNotFound
from .repomanagers import RepoManager
from .tools import Tool
from .diff_parser import Entry

repo_name = 'justinabrahms/imhotep'

with open(fixture_path('remote_pr.json')) as f:
    remote_json_fixture = json.loads(f.read())


def test_run():
    with mock.patch("subprocess.Popen") as popen:
        run('test')
        popen.assert_called_with(['test'],
                                 cwd='.',
                                 stdout=mock.ANY,
                                 shell=True)


def test_run_known_cwd():
    with mock.patch("subprocess.Popen") as popen:
        run('test', cwd="/known")
Ejemplo n.º 4
0
def test_skip_line__index():
    dcp = DiffContextParser("")
    assert dcp.should_skip_line("index 3929bb3..633facf 100644")


def test_skip_line__index_no_permissions():
    dcp = DiffContextParser("")
    assert dcp.should_skip_line("index 0000000..78ce7f6")


def test_skip_line__noskip():
    dcp = DiffContextParser("")
    assert not dcp.should_skip_line("+ this is a legit line")


with open(fixture_path('two-block.diff')) as f:
    two_block = f.read()

with open(fixture_path('two-file.diff')) as f:
    two_file = f.read()


def test_multi_block_single_file():
    dcp = DiffContextParser(two_block)
    results = dcp.parse()
    entry = results[0]

    assert len(entry.added_lines) == 5
    assert len(entry.removed_lines) == 1