OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """Unit tests for git_cl.py.""" | 6 """Unit tests for git_cl.py.""" |
7 | 7 |
8 import json | 8 import json |
9 import os | 9 import os |
10 import StringIO | 10 import StringIO |
(...skipping 2104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2115 'deadbeaf'), | 2115 'deadbeaf'), |
2116 ((['git', 'diff', 'deadbeaf'],), ''), # No diff. | 2116 ((['git', 'diff', 'deadbeaf'],), ''), # No diff. |
2117 ((['git', 'config', 'branch.feature.gerritserver'],), | 2117 ((['git', 'config', 'branch.feature.gerritserver'],), |
2118 'chromium-review.googlesource.com'), | 2118 'chromium-review.googlesource.com'), |
2119 ] | 2119 ] |
2120 cl = git_cl.Changelist(issue=123, codereview='gerrit') | 2120 cl = git_cl.Changelist(issue=123, codereview='gerrit') |
2121 cl._codereview_impl._GetChangeDetail = lambda _: { | 2121 cl._codereview_impl._GetChangeDetail = lambda _: { |
2122 'labels': {}, | 2122 'labels': {}, |
2123 'current_revision': 'deadbeaf', | 2123 'current_revision': 'deadbeaf', |
2124 } | 2124 } |
| 2125 cl._codereview_impl._GetChangeCommit = lambda: { |
| 2126 'commit': 'deadbeef', |
| 2127 'web_links': [{'name': 'gerrit', |
| 2128 'url': 'https://git.googlesource.com/test/+/deadbeef'}], |
| 2129 } |
2125 cl._codereview_impl.SubmitIssue = lambda wait_for_merge: None | 2130 cl._codereview_impl.SubmitIssue = lambda wait_for_merge: None |
2126 out = StringIO.StringIO() | 2131 out = StringIO.StringIO() |
2127 self.mock(sys, 'stdout', out) | 2132 self.mock(sys, 'stdout', out) |
2128 self.assertEqual(0, cl.CMDLand(force=True, bypass_hooks=True, verbose=True)) | 2133 self.assertEqual(0, cl.CMDLand(force=True, bypass_hooks=True, verbose=True)) |
2129 self.assertRegexpMatches(out.getvalue(), 'Issue.*123 has been submitted') | 2134 self.assertRegexpMatches(out.getvalue(), 'Issue.*123 has been submitted') |
| 2135 self.assertRegexpMatches(out.getvalue(), 'Landed as .*deadbeef') |
2130 | 2136 |
2131 BUILDBUCKET_BUILDS_MAP = { | 2137 BUILDBUCKET_BUILDS_MAP = { |
2132 '9000': { | 2138 '9000': { |
2133 'id': '9000', | 2139 'id': '9000', |
2134 'status': 'STARTED', | 2140 'status': 'STARTED', |
2135 'url': 'http://build.cr.org/p/x.y/builders/my-builder/builds/2', | 2141 'url': 'http://build.cr.org/p/x.y/builders/my-builder/builds/2', |
2136 'result_details_json': '{"properties": {}}', | 2142 'result_details_json': '{"properties": {}}', |
2137 'bucket': 'master.x.y', | 2143 'bucket': 'master.x.y', |
2138 'created_by': 'user:someone@chromium.org', | 2144 'created_by': 'user:someone@chromium.org', |
2139 'created_ts': '147200002222000', | 2145 'created_ts': '147200002222000', |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2254 self.assertNotRegexpMatches(sys.stdout.getvalue(), 'Warning') | 2260 self.assertNotRegexpMatches(sys.stdout.getvalue(), 'Warning') |
2255 self.assertRegexpMatches(sys.stdout.getvalue(), '^Failures:') | 2261 self.assertRegexpMatches(sys.stdout.getvalue(), '^Failures:') |
2256 self.assertRegexpMatches(sys.stdout.getvalue(), 'Started:') | 2262 self.assertRegexpMatches(sys.stdout.getvalue(), 'Started:') |
2257 self.assertRegexpMatches(sys.stdout.getvalue(), '2 try jobs') | 2263 self.assertRegexpMatches(sys.stdout.getvalue(), '2 try jobs') |
2258 | 2264 |
2259 | 2265 |
2260 if __name__ == '__main__': | 2266 if __name__ == '__main__': |
2261 git_cl.logging.basicConfig( | 2267 git_cl.logging.basicConfig( |
2262 level=git_cl.logging.DEBUG if '-v' in sys.argv else git_cl.logging.ERROR) | 2268 level=git_cl.logging.DEBUG if '-v' in sys.argv else git_cl.logging.ERROR) |
2263 unittest.main() | 2269 unittest.main() |
OLD | NEW |