Esempio n. 1
0
def test_create_context__missing_key_raises():
    config = build_review_config(fixer_ini)
    with assert_raises(KeyError):
        empty = {}
        fixers.create_context(
            config, empty, clone_path,
            sentinel.repo, sentinel.pull_request)
Esempio n. 2
0
def test_create_context():
    config = build_review_config(fixer_ini, app_config)
    context = fixers.create_context(config, clone_path, sentinel.repo,
                                    sentinel.pull_request)

    eq_('commit', context['strategy'])
    eq_(config['GITHUB_AUTHOR_EMAIL'], context['author_email'])
    eq_(config['GITHUB_AUTHOR_NAME'], context['author_name'])
    eq_(clone_path, context['repo_path'])
    eq_(sentinel.repo, context['repository'])
    eq_(sentinel.pull_request, context['pull_request'])
Esempio n. 3
0
    def test_create_context(self):
        config = build_review_config(fixer_ini, app_config)
        context = fixers.create_context(
            config, clone_path,
            sentinel.repo, sentinel.pull_request)

        self.assertEqual('commit', context['strategy'])
        self.assertEqual(config['GITHUB_AUTHOR_EMAIL'],
                         context['author_email'])
        self.assertEqual(config['GITHUB_AUTHOR_NAME'], context['author_name'])
        self.assertEqual(clone_path, context['repo_path'])
        self.assertEqual(sentinel.repo, context['repository'])
        self.assertEqual(sentinel.pull_request, context['pull_request'])
Esempio n. 4
0
 def apply_fixers(self, tool_list, files_to_check):
     try:
         fixer_context = fixers.create_context(
             self._config,
             self._target_path,
             self._repository,
             self._pull_request,
         )
         fixer_diff = fixers.run_fixers(tool_list, self._target_path,
                                        files_to_check)
         fixers.apply_fixer_diff(self._changes, fixer_diff, fixer_context)
     except (ConfigurationError, WorkflowError) as e:
         log.warn('Fixer application failed. Got %s', e)
         message = u'Unable to apply fixers. {}'.format(e)
         self.problems.add(IssueComment(message))
     except Exception as e:
         log.warn(
             'Fixer application failed, '
             'rolling back working tree. Got %s', e)
         fixers.rollback_changes(self._target_path)
Esempio n. 5
0
 def apply_fixers(self, tool_list, files_to_check):
     try:
         fixer_context = fixers.create_context(
             self._config,
             self._target_path,
             self._repository,
             self._pull_request,
         )
         fixer_diff = fixers.run_fixers(
             tool_list,
             self._target_path,
             files_to_check)
         fixers.apply_fixer_diff(
             self._changes,
             fixer_diff,
             fixer_context)
     except (ConfigurationError, WorkflowError) as e:
         log.info('Fixer application failed. Got %s', e)
         message = u'Unable to apply fixers. {}'.format(e)
         self.problems.add(InfoComment(message))
     except Exception as e:
         log.info('Fixer application failed, '
                  'rolling back working tree. Got %s', e)
         fixers.rollback_changes(self._target_path)