Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_postmerge_gerrit_review_command(self):
pipe = self.getPipeline('postmerge')
# Pick the first Gerrit success reporter
gerrit_reporter = [r for r in pipe.success_actions
if isinstance(r, GerritReporter)][0]
# There is no verified/code-review configured:
self.assertEquals(
{'tag': 'autogenerated:ci'},
gerrit_reporter.reporter_config)
gerrit = GerritConnection('fake_gerrit',
{'server': 'localhost', 'user': 'john'})
# Fake ssh (stdout, stderr) so the command is returned by review()
gerrit._ssh = lambda x: ['', x]
cmd = gerrit.review('some/project', '12345,42', 'hello world',
gerrit_reporter.reporter_config)
self.longMessage = True
self.assertEquals(
'gerrit review --project some/project '
'--message "hello world" --tag autogenerated:ci 12345,42',
cmd,
'gerrit review command does not match Gerrit 2.13 expectation')
def test_all_gerrit_reporters_use_tagged_comment(self):
gerrit = GerritConnection('fake_gerrit',
{'server': 'localhost', 'user': 'jane'})
# Fake ssh (stdout, stderr) so the command is returned by review()
gerrit._ssh = lambda x: ['', x]
errors = []
for pipeline in self.getPipelines():
for action in self.sched._reporter_actions.values():
# Note: when unset:
# merge-failure action defaults to failure action
# disabled action defaults to success action
for reporter in [r for r in getattr(pipeline, action, [])
if isinstance(r, GerritReporter)]:
cmd = gerrit.review(
'some/project', '12345,42',
'%s action on %s pipeline' % (action, pipeline.name),
reporter.reporter_config)