Example #1
0
 def test_factory_generates_tools(self):
     gh = Mock(spec=github3.GitHub)
     config = build_review_config(sample_ini)
     linters = tools.factory(config, Review(gh, None, config), '')
     self.assertEqual(2, len(linters))
     self.assertIsInstance(linters[0], pep8.Pep8)
     self.assertIsInstance(linters[1], jshint.Jshint)
Example #2
0
 def test_factory_generates_tools(self):
     gh = Mock(spec=github3.GitHub)
     config = build_review_config(sample_ini)
     linters = tools.factory(config, Review(gh, None, config), '')
     self.assertEqual(2, len(linters))
     self.assertIsInstance(linters[0], pep8.Pep8)
     self.assertIsInstance(linters[1], jshint.Jshint)
Example #3
0
 def test_run(self):
     config = build_review_config(simple_ini)
     problems = Problems()
     files = ['./tests/fixtures/pep8/has_errors.py']
     tool_list = tools.factory(config, problems, root_dir)
     tools.run(tool_list, files, [])
     self.assertEqual(7, len(problems))
Example #4
0
def test_factory_generates_tools():
    gh = Mock(spec=github3.GitHub)
    config = build_review_config(sample_ini)
    linters = tools.factory(Review(gh, None), config, '')
    eq_(2, len(linters))
    assert isinstance(linters[0], tools.pep8.Pep8)
    assert isinstance(linters[1], tools.jshint.Jshint)
Example #5
0
def test_run():
    config = build_review_config(simple_ini)
    problems = Problems()
    files = ['./tests/fixtures/pep8/has_errors.py']
    tool_list = tools.factory(config, problems, root_dir)
    tools.run(tool_list, files, [])
    eq_(7, len(problems))
Example #6
0
def test_factory_generates_tools():
    gh = Mock(spec=github3.GitHub)
    config = build_review_config(sample_ini)
    linters = tools.factory(Review(gh, None), config, '')
    eq_(2, len(linters))
    assert isinstance(linters[0], tools.pep8.Pep8)
    assert isinstance(linters[1], tools.jshint.Jshint)
Example #7
0
 def test_run__filter_files(self):
     config = build_review_config(simple_ini)
     problems = Problems()
     files = [
         './tests/fixtures/pep8/has_errors.py',
         './tests/fixtures/phpcs/has_errors.php'
     ]
     tool_list = tools.factory(config, problems, root_dir)
     tools.run(tool_list, files, [])
     self.assertEqual(7, len(problems))
Example #8
0
    def test_run_timeout_error(self, mock_docker):
        mock_docker.side_effect = TimeoutError("Read timed out. (read timeout=300)")
        config = build_review_config(simple_ini)
        problems = Problems()
        files = ['./tests/fixtures/pep8/has_errors.py']
        tool_list = tools.factory(config, problems, root_dir)
        tools.run(tool_list, files, [])

        errors = problems.all()
        assert 1 == len(errors)
        assert 'timed out during' in errors[0].body
        assert 'run pep8 linter' in errors[0].body
Example #9
0
    def test_run_timeout_error(self, mock_docker):
        mock_docker.side_effect = TimeoutError(
            "Read timed out. (read timeout=300)")
        config = build_review_config(simple_ini)
        problems = Problems()
        files = ['./tests/fixtures/pep8/has_errors.py']
        tool_list = tools.factory(config, problems, root_dir)
        tools.run(tool_list, files, [])

        errors = problems.all()
        assert 1 == len(errors)
        assert 'timed out during' in errors[0].body
        assert 'run pep8 linter' in errors[0].body
Example #10
0
    def run_tools(self, review_config):
        if self._changes is None:
            raise RuntimeError('No loaded changes, cannot run tools. '
                               'Try calling load_changes first.')
        files_to_check = self._changes.get_files(
            ignore_patterns=review_config.ignore_patterns())
        commits_to_check = self._pull_request.commits()

        tool_list = tools.factory(review_config, self.problems,
                                  self._target_path)

        if review_config.fixers_enabled():
            self.apply_fixers(review_config, tool_list, files_to_check)

        tools.run(tool_list, files_to_check, commits_to_check)
Example #11
0
    def run_tools(self):
        if self._changes is None:
            raise RuntimeError('No loaded changes, cannot run tools. '
                               'Try calling load_changes first.')
        config = self._config

        files_to_check = self._changes.get_files(
            ignore_patterns=config.ignore_patterns()
        )
        commits_to_check = self._pull_request.commits()

        tool_list = tools.factory(
            config,
            self.problems,
            self._target_path)

        if config.fixers_enabled():
            self.apply_fixers(tool_list, files_to_check)

        tools.run(tool_list, files_to_check, commits_to_check)
Example #12
0
 def test_tool_repr(self):
     gh = Mock(spec=github3.GitHub)
     config = build_review_config(sample_ini)
     linters = tools.factory(config, Review(gh, None, config), '')
     self.assertIn('<pep8Tool config:', str(linters[0]))
Example #13
0
def test_factory_raises_error_on_bad_linter():
    gh = Mock(spec=github3.GitHub)
    config = build_review_config(bad_ini)
    config = ReviewConfig()
    config.load_ini(bad_ini)
    tools.factory(Review(gh, None), config, '')
Example #14
0
 def test_tool_repr(self):
     gh = Mock(spec=github3.GitHub)
     config = build_review_config(sample_ini)
     linters = tools.factory(config, Review(gh, None, config), '')
     self.assertIn('<pep8Tool config:', str(linters[0]))
Example #15
0
def test_factory_raises_error_on_bad_linter():
    gh = Mock(spec=github3.GitHub)
    config = build_review_config(bad_ini)
    config = ReviewConfig()
    config.load_ini(bad_ini)
    tools.factory(Review(gh, None), config, '')
Example #16
0
def test_factory_generates_tools():
    config = ReviewConfig(sample_ini)
    linters = tools.factory(Review(None, None), config, '')
    eq_(2, len(linters))
    assert isinstance(linters[0], tools.pep8.Pep8)
    assert isinstance(linters[1], tools.jshint.Jshint)
Example #17
0
def test_factory_raises_error_on_bad_linter():
    config = ReviewConfig(bad_ini)
    tools.factory(Review(None, None), config, '')