Index: tests/git_cl_test.py |
diff --git a/tests/git_cl_test.py b/tests/git_cl_test.py |
index 3e3b591952bdb48ea42dd65c4d0d8ab1ba35f345..90647a713a04f1fe2930a6c784871ca75f615c55 100755 |
--- a/tests/git_cl_test.py |
+++ b/tests/git_cl_test.py |
@@ -5,9 +5,9 @@ |
"""Unit tests for git_cl.py.""" |
+import json |
import os |
import StringIO |
-import stat |
import sys |
import unittest |
import urlparse |
@@ -1836,7 +1836,7 @@ class TestGitCl(TestCase): |
] |
self.assertEqual(0, git_cl.main(['issue', '--json', 'output.json'])) |
- def test_git_cl_try_default(self): |
+ def test_git_cl_try_default_cq_dry_run(self): |
self.mock(git_cl.Changelist, 'GetChange', |
lambda _, *a: ( |
self._mocked_call(['GetChange']+list(a)))) |
@@ -1874,6 +1874,63 @@ class TestGitCl(TestCase): |
out.getvalue(), |
'scheduled CQ Dry Run on https://codereview.chromium.org/123\n') |
+ def test_git_cl_try_buildbucket_with_properties(self): |
+ self.mock(git_cl.Changelist, 'GetMostRecentPatchset', lambda _: 20001) |
+ self.mock(git_cl.Changelist, 'GetIssueOwner', lambda _: 'owner@e.mail') |
+ self.mock(git_cl.Changelist, 'GetIssueProject', lambda _: 'depot_tools') |
+ self.mock(git_cl.uuid, 'uuid4', lambda: 'uuid4') |
+ self.calls = [ |
+ ((['git', 'symbolic-ref', 'HEAD'],), 'feature'), |
+ ((['git', 'config', 'branch.feature.rietveldissue'],), '123'), |
+ ((['git', 'config', 'rietveld.autoupdate'],), CERR1), |
+ ((['git', 'config', 'rietveld.server'],), |
+ 'https://codereview.chromium.org'), |
+ ((['git', 'config', 'branch.feature.rietveldserver'],), CERR1), |
+ ((['git', 'config', 'branch.feature.rietveldpatchset'],), '20001'), |
+ ] |
+ |
+ def _buildbucket_retry(*_, **kw): |
+ # self.maxDiff = 10000 |
+ body = json.loads(kw['body']) |
+ self.assertEqual(len(body['builds']), 1) |
+ build = body['builds'][0] |
+ params = json.loads(build.pop('parameters_json')) |
+ self.assertEqual(params, { |
+ u'builder_name': u'win', |
+ u'changes': [{u'author': {u'email': u'owner@e.mail'}, |
+ u'revision': None}], |
+ u'properties': { |
+ u'category': u'git_cl_try', |
+ u'issue': 123, |
+ u'key': u'val', |
+ u'json': [{u'a': 1}, None], |
+ u'master': u'tryserver.chromium', |
+ u'patch_project': u'depot_tools', |
+ u'patch_storage': u'rietveld', |
+ u'patchset': 20001, |
+ u'reason': u'feature', # This is a branch name, but why? |
+ u'rietveld': u'https://codereview.chromium.org', |
+ } |
+ }) |
+ self.assertEqual(build, { |
+ u'bucket': u'master.tryserver.chromium', |
+ u'client_operation_id': u'uuid4', |
+ u'tags': [u'builder:win', |
+ u'buildset:patch/rietveld/codereview.chromium.org/123/20001', |
+ u'master:tryserver.chromium', |
+ u'user_agent:git_cl_try'], |
+ }) |
+ |
+ self.mock(git_cl, '_buildbucket_retry', _buildbucket_retry) |
+ |
+ self.mock(git_cl.sys, 'stdout', StringIO.StringIO()) |
+ self.assertEqual(0, git_cl.main([ |
+ 'try', '-m', 'tryserver.chromium', '-b', 'win', |
+ '-p', 'key=val', '-p', 'json=[{"a":1}, null]'])) |
+ self.assertRegexpMatches( |
+ git_cl.sys.stdout.getvalue(), |
+ 'Tried jobs on:\nMaster: tryserver.chromium') |
+ |
def _common_GerritCommitMsgHookCheck(self): |
self.mock(git_cl.sys, 'stdout', StringIO.StringIO()) |
self.mock(git_cl.os.path, 'abspath', |