コード例 #1
0
def test_yamllint_a_yml(app, pr_context):
    diff = """diff --git a/a.yml b/a.yml
new file mode 100644
index 0000000..1eccee8
--- /dev/null
+++ b/a.yml
@@ -0,0 +1,3 @@
+---
+a: 1
+a: 2
"""

    spec = Specification()
    spec.linters.append(ObjectDict(name='yamllint', pattern=None))
    lint = LintProcessor(pr_context, spec,
                         os.path.join(FIXTURES_PATH, 'yamllint'))
    patch = PatchSet(diff.split('\n'))
    with mock.patch.object(lint, 'load_changes') as load_changes,\
            mock.patch.object(lint, 'update_build_status') as build_status,\
            mock.patch.object(lint, '_report') as report:
        load_changes.return_value = patch
        build_status.return_value = None
        report.return_value = (1, 2)
        lint.problems.set_changes(patch)
        lint.process()

        assert load_changes.called

    assert len(lint.problems) == 1
    problem = lint.problems[0]
    assert problem.filename == 'a.yml'
    assert problem.line == 3
コード例 #2
0
def test_bandit_lint_a_py(app, pr_context):
    diff = """diff --git a/a.py b/a.py
new file mode 100644
index 0000000..719cd56
--- /dev/null
+++ b/a.py
@@ -0,0 +1,4 @@
+try:
+    a = 1
+except Exception:
+    pass
"""

    spec = Specification()
    spec.linters.append(ObjectDict(name='bandit'))
    lint = LintProcessor(pr_context, spec,
                         os.path.join(FIXTURES_PATH, 'bandit'))
    patch = PatchSet(diff.split('\n'))
    with mock.patch.object(lint, 'load_changes') as load_changes,\
            mock.patch.object(lint, 'update_build_status') as build_status,\
            mock.patch.object(lint, '_report') as report:
        load_changes.return_value = patch
        build_status.return_value = None
        report.return_value = (1, 2)
        lint.problems.set_changes(patch)
        lint.process()

        assert load_changes.called

    assert len(lint.problems) == 1
    problem = lint.problems[0]
    assert problem.filename == 'a.py'
    assert problem.line == 3
    assert not problem.is_error
コード例 #3
0
def test_jsonlint_a_json_changes_out_of_range(app, pr_context):
    diff = """diff --git a/c.json b/c.json
index 9b90002..c36a2a4 100644
--- a/c.json
+++ b/c.json
@@ -3,4 +3,5 @@
     "b": 2,
     c: 3,
     d: 4
+    e: 5
 }
"""

    spec = Specification()
    spec.linters.append(ObjectDict(name='jsonlint', pattern=None))
    lint = LintProcessor(pr_context, spec,
                         os.path.join(FIXTURES_PATH, 'jsonlint'))
    patch = PatchSet(diff.split('\n'))
    with mock.patch.object(lint, 'load_changes') as load_changes,\
            mock.patch.object(lint, 'update_build_status') as build_status,\
            mock.patch.object(lint, '_report') as report:
        load_changes.return_value = patch
        build_status.return_value = None
        report.return_value = (1, 2)
        lint.problems.set_changes(patch)
        lint.process()

        assert load_changes.called

    assert len(lint.problems) == 0
コード例 #4
0
def test_shellcheck_a_sh(app, pr_context):
    diff = """diff --git a/a.sh b/a.sh
new file mode 100644
index 0000000..9fb9840
--- /dev/null
+++ b/a.sh
@@ -0,0 +2 @@
+#!/bin/sh
+$foo=42
"""

    spec = Specification()
    spec.linters.append(ObjectDict(name='shellcheck', pattern=None))
    lint = LintProcessor(pr_context, spec,
                         os.path.join(FIXTURES_PATH, 'shellcheck'))
    patch = PatchSet(diff.split('\n'))
    with mock.patch.object(lint, 'load_changes') as load_changes,\
            mock.patch.object(lint, 'update_build_status') as build_status,\
            mock.patch.object(lint, '_report') as report:
        load_changes.return_value = patch
        build_status.return_value = None
        report.return_value = (1, 2)
        lint.problems.set_changes(patch)
        lint.process()

        assert load_changes.called

    assert len(lint.problems) > 0
    problem = lint.problems[0]
    assert problem.filename == 'a.sh'
    assert problem.line == 2
コード例 #5
0
def test_stylelint_lint_a_scss(app, pr_context):
    diff = """diff --git a/a.scss b/a.scss
new file mode 100644
index 0000000..e545209
--- /dev/null
+++ b/a.scss
@@ -0,0 +1 @@
+a[id="foo"] { content: "x"; }
"""

    spec = Specification()
    spec.linters.append(ObjectDict(name='stylelint', pattern=None))
    lint = LintProcessor(pr_context, spec,
                         os.path.join(FIXTURES_PATH, 'stylelint'))
    patch = PatchSet(diff.split('\n'))
    with mock.patch.object(lint, 'load_changes') as load_changes,\
            mock.patch.object(lint, 'update_build_status') as build_status,\
            mock.patch.object(lint, '_report') as report:
        load_changes.return_value = patch
        build_status.return_value = None
        report.return_value = (1, 2)
        lint.problems.set_changes(patch)
        lint.process()

        assert load_changes.called

    assert len(lint.problems) == 2
    problem = lint.problems[0]
    assert problem.filename == 'a.scss'
コード例 #6
0
def test_jsonlint_a_json_changes_in_range(app, pr_context):
    diff = """diff --git a/b.json b/b.json
index 6ebebfe..6be8d74 100644
--- a/b.json
+++ b/b.json
@@ -1,3 +1,4 @@
 {
     "a": 1
+    "b": 2
 }
"""

    spec = Specification()
    spec.linters.append(ObjectDict(name='jsonlint', pattern=None))
    lint = LintProcessor(pr_context, spec,
                         os.path.join(FIXTURES_PATH, 'jsonlint'))
    patch = PatchSet(diff.split('\n'))
    with mock.patch.object(lint, 'load_changes') as load_changes,\
            mock.patch.object(lint, 'update_build_status') as build_status,\
            mock.patch.object(lint, '_report') as report:
        load_changes.return_value = patch
        build_status.return_value = None
        report.return_value = (1, 2)
        lint.problems.set_changes(patch)
        lint.process()

        assert load_changes.called

    assert len(lint.problems) == 1
    problem = lint.problems[0]
    assert problem.filename == 'b.json'
    assert problem.line == 2
コード例 #7
0
def test_hadolint_lint_a_dockerfile(app, pr_context):
    diff = """diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..cd19857
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,3 @@
+FROM ubuntu:16.04
+
+RUN apt-get update && apt-get install file
"""

    spec = Specification()
    spec.linters.append(ObjectDict(name='hadolint', pattern=None))
    lint = LintProcessor(pr_context, spec,
                         os.path.join(FIXTURES_PATH, 'hadolint'))
    patch = PatchSet(diff.split('\n'))
    with mock.patch.object(lint, 'load_changes') as load_changes,\
            mock.patch.object(lint, 'update_build_status') as build_status,\
            mock.patch.object(lint, '_report') as report:
        load_changes.return_value = patch
        build_status.return_value = None
        report.return_value = (1, 2)
        lint.problems.set_changes(patch)
        lint.process()

        assert load_changes.called

    assert len(lint.problems) == 4
    problem = lint.problems[0]
    assert problem.line == 3
    assert problem.filename == 'Dockerfile'
コード例 #8
0
def test_flake8_lint_a_py(app, pr_context):
    diff = """diff --git a/a.py b/a.py
new file mode 100644
index 0000000..fdeea15
--- /dev/null
+++ b/a.py
@@ -0,0 +1,6 @@
+# -*- coding: utf-8 -*-
+from __future__ import absolute_import, unicode_literals
+
+
+def add(a, b):
+    return a+ b
"""

    spec = Specification()
    spec.linters.append(ObjectDict(name='flake8', pattern=None))
    lint = LintProcessor(pr_context, spec,
                         os.path.join(FIXTURES_PATH, 'flake8'))
    patch = PatchSet(diff.split('\n'))
    with mock.patch.object(lint, 'load_changes') as load_changes,\
            mock.patch.object(lint, 'update_build_status') as build_status,\
            mock.patch.object(lint, '_report') as report:
        load_changes.return_value = patch
        build_status.return_value = None
        report.return_value = (1, 2)
        lint.problems.set_changes(patch)
        lint.process()

        assert load_changes.called

    assert len(lint.problems) == 1
    problem = lint.problems[0]
    assert problem.filename == 'a.py'
    assert problem.line == 6
コード例 #9
0
ファイル: test_lint.py プロジェクト: aflp91/badwolf
def test_no_changed_files_ignore(app, caplog):
    diff = """diff --git a/removed_file b/removed_file
deleted file mode 100644
index 1f38447..0000000
--- a/removed_file
+++ /dev/null
@@ -1,3 +0,0 @@
-This content shouldn't be here.
-
-This file will be removed.
"""

    context = TestContext('deepanalyzer/badwolf',
                          None,
                          'pullrequest',
                          'message', {'commit': {
                              'hash': '000000'
                          }}, {'commit': {
                              'hash': '111111'
                          }},
                          pr_id=1)
    spec = Specification()
    spec.linters.append(ObjectDict(name='flake8', pattern=None))
    lint = LintProcessor(context, spec, '/tmp')
    patch = PatchSet(diff.split('\n'))
    with mock.patch.object(lint, 'load_changes') as load_changes:
        load_changes.return_value = patch
        lint.process()

        assert load_changes.called

    assert 'No changed files found' in caplog.text()
コード例 #10
0
def test_rstlint_a_rst(app, pr_context):
    diff = """diff --git a/a.rst b/a.rst
new file mode 100644
index 0000000..4e46cf9
--- /dev/null
+++ b/a.rst
@@ -0,0 +1,2 @@
+Hello World
+====
"""

    spec = Specification()
    spec.linters.append(ObjectDict(name='rstlint'))
    lint = LintProcessor(pr_context, spec,
                         os.path.join(FIXTURES_PATH, 'rstlint'))
    patch = PatchSet(diff.split('\n'))
    with mock.patch.object(lint, 'load_changes') as load_changes,\
            mock.patch.object(lint, 'update_build_status') as build_status,\
            mock.patch.object(lint, '_report') as report:
        load_changes.return_value = patch
        build_status.return_value = None
        report.return_value = (1, 2)
        lint.problems.set_changes(patch)
        lint.process()

        assert load_changes.called

    assert len(lint.problems) == 1
    problem = lint.problems[0]
    assert problem.filename == 'a.rst'
    assert problem.line == 2
コード例 #11
0
def test_mypy_lint_a_py(app, pr_context):
    diff = """diff --git a/a.py b/a.py
new file mode 100644
index 0000000..87604af
--- /dev/null
+++ b/a.py
@@ -0,0 +1,5 @@
+def p() -> None:
+    print('hello')
+
+
+a = p()
"""

    spec = Specification()
    spec.linters.append(ObjectDict(name='mypy', pattern=None))
    lint = LintProcessor(pr_context, spec, os.path.join(FIXTURES_PATH, 'mypy'))
    patch = PatchSet(diff.split('\n'))
    with mock.patch.object(lint, 'load_changes') as load_changes,\
            mock.patch.object(lint, 'update_build_status') as build_status,\
            mock.patch.object(lint, '_report') as report:
        load_changes.return_value = patch
        build_status.return_value = None
        report.return_value = (1, 2)
        lint.problems.set_changes(patch)
        lint.process()

        assert load_changes.called

    assert len(lint.problems) == 1
    problem = lint.problems[0]
    assert problem.line == 5
    assert problem.filename == 'a.py'
コード例 #12
0
ファイル: spec.py プロジェクト: julypanda/badwolf
    def _parse_linters(cls, linters):
        ret = []
        for linter in linters:
            info = ObjectDict()
            if isinstance(linter, dict):
                name = linter.get('name')
                pattern = linter.get('pattern')
                if not name:
                    continue

                info.update(linter)
            else:
                name = linter
                pattern = None

            info['name'] = name.strip()
            info['pattern'] = pattern
            ret.append(info)

        return ret
コード例 #13
0
ファイル: spec.py プロジェクト: SchuckBeta/badwolf
 def __init__(self):
     self.image = None
     self.services = []
     self.scripts = []
     self.dockerfile = 'Dockerfile'
     self.docker = False  # Bind Docker sock to container or not
     self.after_success = []
     self.after_failure = []
     self.notification = ObjectDict(
         email=None,
         slack_webhook=None,
     )
     self.branch = set()
     self.environments = []
     self.linters = []
     self.privileged = False
     self.deploy = []
     self.after_deploy = []
     self.artifacts = ObjectDict(paths=[], excludes=[])
     self.vault = ObjectDict(url=None, token=None, env=ObjectDict())
コード例 #14
0
ファイル: spec.py プロジェクト: xa-Amour/badwolf
 def _postprocess(self, data, **kwargs):
     # vault.envs format should be:
     # ENV_NAME secret/path:key
     env_map = ObjectDict()
     for env in data['env']:
         try:
             name, path_key = env.strip().split(' ', 1)
             path, key = path_key.strip().split(':', 1)
         except ValueError:
             raise ValidationError('Invalid vault env {}'.format(name),
                                   'env')
         env_map[name] = (path, key)
     data['env'] = env_map
     return super()._postprocess(data, **kwargs)
コード例 #15
0
ファイル: spec.py プロジェクト: julypanda/badwolf
 def __init__(self):
     self.services = []
     self.scripts = []
     self.dockerfile = 'Dockerfile'
     self.after_success = []
     self.after_failure = []
     self.notification = ObjectDict(
         emails=[],
         slack_webhooks=[],
     )
     self.branch = set()
     self.environments = []
     self.linters = []
     self.privileged = False
コード例 #16
0
ファイル: test_lint.py プロジェクト: aflp91/badwolf
def test_eslint_lint_a_js(app, caplog):
    diff = """diff --git a/.eslintrc b/.eslintrc
new file mode 100644
index 0000000..45e5d69
--- /dev/null
+++ b/.eslintrc
@@ -0,0 +1,5 @@
+{
+    "rules": {
+        "quotes": [2, "single"]
+    }
+}
diff --git a/a.js b/a.js
new file mode 100644
index 0000000..f119a7f
--- /dev/null
+++ b/a.js
@@ -0,0 +1 @@
+console.log("bar")
"""

    context = TestContext('deepanalyzer/badwolf',
                          None,
                          'pullrequest',
                          'message', {'commit': {
                              'hash': '000000'
                          }}, {'commit': {
                              'hash': '111111'
                          }},
                          pr_id=1)
    spec = Specification()
    spec.linters.append(ObjectDict(name='eslint', pattern=None))
    lint = LintProcessor(context, spec, os.path.join(FIXTURES_PATH, 'eslint'))
    patch = PatchSet(diff.split('\n'))
    with mock.patch.object(lint, 'load_changes') as load_changes,\
            mock.patch.object(lint, 'update_build_status') as build_status,\
            mock.patch.object(lint, '_report') as report:
        load_changes.return_value = patch
        build_status.return_value = None
        report.return_value = None
        lint.problems.set_changes(patch)
        lint.process()

        assert load_changes.called

    assert len(lint.problems) == 1
    problem = lint.problems[0]
    assert problem.filename == 'a.js'
    assert problem.line == 1
コード例 #17
0
ファイル: test_lint.py プロジェクト: aflp91/badwolf
def test_jscs_lint_a_js(app, caplog):
    diff = """diff --git a/.jscsrc b/.jscsrc
new file mode 100644
index 0000000..c287019
--- /dev/null
+++ b/.jscsrc
@@ -0,0 +1,3 @@
+{
+       "preset": "node-style-guide"
+}
\ No newline at end of file
diff --git a/jscs/a.js b/a.js
new file mode 100644
index 0000000..66f319a
--- /dev/null
+++ b/a.js
@@ -0,0 +1,2 @@
+var foo = 'bar';
+if(foo  === 'bar') {}
"""

    context = TestContext('deepanalyzer/badwolf',
                          None,
                          'pullrequest',
                          'message', {'commit': {
                              'hash': '000000'
                          }}, {'commit': {
                              'hash': '111111'
                          }},
                          pr_id=1)
    spec = Specification()
    spec.linters.append(ObjectDict(name='jscs', pattern=None))
    lint = LintProcessor(context, spec, os.path.join(FIXTURES_PATH, 'jscs'))
    patch = PatchSet(diff.split('\n'))
    with mock.patch.object(lint, 'load_changes') as load_changes,\
            mock.patch.object(lint, 'update_build_status') as build_status,\
            mock.patch.object(lint, '_report') as report:
        load_changes.return_value = patch
        build_status.return_value = None
        report.return_value = None
        lint.problems.set_changes(patch)
        lint.process()

        assert load_changes.called

    assert len(lint.problems) == 1
    problem = lint.problems[0]
    assert problem.filename == 'a.js'
    assert problem.line == 2
コード例 #18
0
ファイル: test_lint.py プロジェクト: aflp91/badwolf
def test_flake8_lint_a_py_with_multi_custom_glob_patterns(app, caplog):
    diff = """diff --git a/b.pyx b/b.pyx
new file mode 100644
index 0000000..fdeea15
--- /dev/null
+++ b/b.pyx
@@ -0,0 +1,6 @@
+# -*- coding: utf-8 -*-
+from __future__ import absolute_import, unicode_literals
+
+
+def add(a, b):
+    return a+ b
"""

    context = TestContext('deepanalyzer/badwolf',
                          None,
                          'pullrequest',
                          'message', {'commit': {
                              'hash': '000000'
                          }}, {'commit': {
                              'hash': '111111'
                          }},
                          pr_id=1)
    spec = Specification()
    spec.linters.append(ObjectDict(name='flake8', pattern='*.py *.pyx'))
    lint = LintProcessor(context, spec, os.path.join(FIXTURES_PATH, 'flake8'))
    patch = PatchSet(diff.split('\n'))
    with mock.patch.object(lint, 'load_changes') as load_changes,\
            mock.patch.object(lint, 'update_build_status') as build_status,\
            mock.patch.object(lint, '_report') as report:
        load_changes.return_value = patch
        build_status.return_value = None
        report.return_value = None
        lint.problems.set_changes(patch)
        lint.process()

        assert load_changes.called

    assert len(lint.problems) == 1
    problem = lint.problems[0]
    assert problem.filename == 'b.pyx'
    assert problem.line == 6
コード例 #19
0
ファイル: test_lint.py プロジェクト: aflp91/badwolf
def test_bandit_lint_a_py(app, caplog):
    diff = """diff --git a/a.py b/a.py
new file mode 100644
index 0000000..719cd56
--- /dev/null
+++ b/a.py
@@ -0,0 +1,4 @@
+try:
+    a = 1
+except Exception:
+    pass
"""

    context = TestContext('deepanalyzer/badwolf',
                          None,
                          'pullrequest',
                          'message', {'commit': {
                              'hash': '000000'
                          }}, {'commit': {
                              'hash': '111111'
                          }},
                          pr_id=1)
    spec = Specification()
    spec.linters.append(ObjectDict(name='bandit'))
    lint = LintProcessor(context, spec, os.path.join(FIXTURES_PATH, 'bandit'))
    patch = PatchSet(diff.split('\n'))
    with mock.patch.object(lint, 'load_changes') as load_changes,\
            mock.patch.object(lint, 'update_build_status') as build_status,\
            mock.patch.object(lint, '_report') as report:
        load_changes.return_value = patch
        build_status.return_value = None
        report.return_value = None
        lint.problems.set_changes(patch)
        lint.process()

        assert load_changes.called

    assert len(lint.problems) == 1
    problem = lint.problems[0]
    assert problem.filename == 'a.py'
    assert problem.line == 3
    assert not problem.is_error
コード例 #20
0
ファイル: test_lint.py プロジェクト: aflp91/badwolf
def test_yamllint_a_yml(app, caplog):
    diff = """diff --git a/a.yml b/a.yml
new file mode 100644
index 0000000..1eccee8
--- /dev/null
+++ b/a.yml
@@ -0,0 +1,3 @@
+---
+a: 1
+a: 2
"""

    context = TestContext('deepanalyzer/badwolf',
                          None,
                          'pullrequest',
                          'message', {'commit': {
                              'hash': '000000'
                          }}, {'commit': {
                              'hash': '111111'
                          }},
                          pr_id=1)
    spec = Specification()
    spec.linters.append(ObjectDict(name='yamllint', pattern=None))
    lint = LintProcessor(context, spec, os.path.join(FIXTURES_PATH,
                                                     'yamllint'))
    patch = PatchSet(diff.split('\n'))
    with mock.patch.object(lint, 'load_changes') as load_changes,\
            mock.patch.object(lint, 'update_build_status') as build_status,\
            mock.patch.object(lint, '_report') as report:
        load_changes.return_value = patch
        build_status.return_value = None
        report.return_value = None
        lint.problems.set_changes(patch)
        lint.process()

        assert load_changes.called

    assert len(lint.problems) == 1
    problem = lint.problems[0]
    assert problem.filename == 'a.yml'
    assert problem.line == 3
コード例 #21
0
def test_sasslint_lint_a_scss(app, caplog):
    diff = """diff --git a/a.scss b/a.scss
new file mode 100644
index 0000000..48b3ebe
--- /dev/null
+++ b/a.scss
@@ -0,0 +1,3 @@
+.test {
+    background-color: "#FFF"
+}
"""

    context = Context('deepanalyzer/badwolf',
                      None,
                      'pullrequest',
                      'message', {'commit': {
                          'hash': '000000'
                      }}, {'commit': {
                          'hash': '111111'
                      }},
                      pr_id=1)
    spec = Specification()
    spec.linters.append(ObjectDict(name='sasslint', pattern=None))
    lint = LintProcessor(context, spec, os.path.join(FIXTURES_PATH,
                                                     'sasslint'))
    patch = PatchSet(diff.split('\n'))
    with mock.patch.object(lint, 'load_changes') as load_changes,\
            mock.patch.object(lint, 'update_build_status') as build_status,\
            mock.patch.object(lint, '_report') as report:
        load_changes.return_value = patch
        build_status.return_value = None
        report.return_value = None
        lint.problems.set_changes(patch)
        lint.process()

        assert load_changes.called

    assert len(lint.problems) == 3
    problem = lint.problems[0]
    assert problem.filename == 'a.scss'
コード例 #22
0
def test_shellcheck_a_sh(app, caplog):
    diff = """diff --git a/a.sh b/a.sh
new file mode 100644
index 0000000..9fb9840
--- /dev/null
+++ b/a.sh
@@ -0,0 +2 @@
+#!/bin/sh
+$foo=42
"""

    context = Context('deepanalyzer/badwolf',
                      None,
                      'pullrequest',
                      'message', {'commit': {
                          'hash': '000000'
                      }}, {'commit': {
                          'hash': '111111'
                      }},
                      pr_id=1)
    spec = Specification()
    spec.linters.append(ObjectDict(name='shellcheck', pattern=None))
    lint = LintProcessor(context, spec,
                         os.path.join(FIXTURES_PATH, 'shellcheck'))
    patch = PatchSet(diff.split('\n'))
    with mock.patch.object(lint, 'load_changes') as load_changes,\
            mock.patch.object(lint, 'update_build_status') as build_status,\
            mock.patch.object(lint, '_report') as report:
        load_changes.return_value = patch
        build_status.return_value = None
        report.return_value = None
        lint.problems.set_changes(patch)
        lint.process()

        assert load_changes.called

    assert len(lint.problems) > 0
    problem = lint.problems[0]
    assert problem.filename == 'a.sh'
    assert problem.line == 2
コード例 #23
0
ファイル: test_lint.py プロジェクト: pombredanne/badwolf-1
def test_jsonlint_a_json_changes_out_of_range(app, caplog):
    diff = """diff --git a/c.json b/c.json
index 9b90002..c36a2a4 100644
--- a/c.json
+++ b/c.json
@@ -3,4 +3,5 @@
     "b": 2,
     c: 3,
     d: 4
+    e: 5
 }
"""

    context = Context(
        'deepanalyzer/badwolf',
        None,
        'pullrequest',
        'message',
        {'commit': {'hash': '000000'}},
        {'commit': {'hash': '111111'}},
        pr_id=1
    )
    spec = Specification()
    spec.linters.append(ObjectDict(name='jsonlint', pattern=None))
    lint = LintProcessor(context, spec, os.path.join(FIXTURES_PATH, 'jsonlint'))
    patch = PatchSet(diff.split('\n'))
    with mock.patch.object(lint, 'load_changes') as load_changes,\
            mock.patch.object(lint, 'update_build_status') as build_status,\
            mock.patch.object(lint, '_report') as report:
        load_changes.return_value = patch
        build_status.return_value = None
        report.return_value = (1, 2)
        lint.problems.set_changes(patch)
        lint.process()

        assert load_changes.called

    assert len(lint.problems) == 0
コード例 #24
0
def test_no_changed_files_ignore(app, pr_context, caplog):
    diff = """diff --git a/removed_file b/removed_file
deleted file mode 100644
index 1f38447..0000000
--- a/removed_file
+++ /dev/null
@@ -1,3 +0,0 @@
-This content shouldn't be here.
-
-This file will be removed.
"""

    spec = Specification()
    spec.linters.append(ObjectDict(name='flake8', pattern=None))
    lint = LintProcessor(pr_context, spec, '/tmp')
    patch = PatchSet(diff.split('\n'))
    with mock.patch.object(lint, 'load_changes') as load_changes:
        load_changes.return_value = patch
        lint.process()

        assert load_changes.called

    assert 'No changed files found' in caplog.text
コード例 #25
0
ファイル: spec.py プロジェクト: xa-Amour/badwolf
 def _postprocess(self, data, **kwargs):
     return ObjectDict(data)
コード例 #26
0
ファイル: spec.py プロジェクト: xa-Amour/badwolf
 def _postprocess(self, data, **kwargs):
     data.update(self.__additional_values.pop(data['name'], {}))
     return ObjectDict(data)
コード例 #27
0
ファイル: spec.py プロジェクト: suclike/badwolf
 def _postprocess(self, data):
     data.update(self.__additional_values)
     return ObjectDict(data)
コード例 #28
0
ファイル: spec.py プロジェクト: suclike/badwolf
 def _postprocess(self, data):
     return ObjectDict(data)