| OLD | NEW |
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import unittest | 5 import unittest |
| 6 | 6 |
| 7 from webkitpy.common.host_mock import MockHost | 7 from webkitpy.common.host_mock import MockHost |
| 8 from webkitpy.common.net.buildbot import Build | 8 from webkitpy.common.net.buildbot import Build |
| 9 from webkitpy.common.net.git_cl import GitCL | 9 from webkitpy.common.net.git_cl import GitCL |
| 10 from webkitpy.common.system.executive_mock import MockExecutive | 10 from webkitpy.common.system.executive_mock import MockExecutive |
| 11 | 11 |
| 12 | 12 |
| 13 class GitCLTest(unittest.TestCase): | 13 class GitCLTest(unittest.TestCase): |
| 14 | 14 |
| 15 def test_run(self): | 15 def test_run(self): |
| 16 host = MockHost() | 16 host = MockHost() |
| 17 host.executive = MockExecutive(output='mock-output') | 17 host.executive = MockExecutive(output='mock-output') |
| 18 git_cl = GitCL(host) | 18 git_cl = GitCL(host) |
| 19 output = git_cl.run(['command']) | 19 output = git_cl.run(['command']) |
| 20 self.assertEqual(output, 'mock-output') | 20 self.assertEqual(output, 'mock-output') |
| 21 self.assertEqual(host.executive.calls, [['git', 'cl', 'command']]) | 21 self.assertEqual(host.executive.calls, [['git', 'cl', 'command']]) |
| 22 | 22 |
| 23 def test_run_with_auth(self): | 23 def test_run_basic(self): |
| 24 host = MockHost() | 24 host = MockHost() |
| 25 host.executive = MockExecutive(output='mock-output') | 25 host.executive = MockExecutive(output='mock-output') |
| 26 git_cl = GitCL(host, auth_refresh_token_json='token.json') | 26 git_cl = GitCL(host) |
| 27 git_cl.run(['upload']) | 27 git_cl.run(['upload']) |
| 28 self.assertEqual( | 28 self.assertEqual(host.executive.calls, [['git', 'cl', 'upload']]) |
| 29 host.executive.calls, | |
| 30 [['git', 'cl', 'upload', '--auth-refresh-token-json', 'token.json']]
) | |
| 31 | |
| 32 def test_some_commands_not_run_with_auth(self): | |
| 33 host = MockHost() | |
| 34 host.executive = MockExecutive(output='mock-output') | |
| 35 git_cl = GitCL(host, auth_refresh_token_json='token.json') | |
| 36 git_cl.run(['issue']) | |
| 37 self.assertEqual(host.executive.calls, [['git', 'cl', 'issue']]) | |
| 38 | 29 |
| 39 def test_get_issue_number(self): | 30 def test_get_issue_number(self): |
| 40 host = MockHost() | 31 host = MockHost() |
| 41 host.executive = MockExecutive(output='Issue number: 12345 (http://crrev
.com/12345)') | 32 host.executive = MockExecutive(output='Issue number: 12345 (http://crrev
.com/12345)') |
| 42 git_cl = GitCL(host) | 33 git_cl = GitCL(host) |
| 43 self.assertEqual(git_cl.get_issue_number(), '12345') | 34 self.assertEqual(git_cl.get_issue_number(), '12345') |
| 44 | 35 |
| 45 def test_get_issue_number_none(self): | 36 def test_get_issue_number_none(self): |
| 46 host = MockHost() | 37 host = MockHost() |
| 47 host.executive = MockExecutive(output='Issue number: None (None)') | 38 host.executive = MockExecutive(output='Issue number: None (None)') |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 { | 164 { |
| 174 'builder_name': 'builder-c', | 165 'builder_name': 'builder-c', |
| 175 'status': 'COMPLETED', | 166 'status': 'COMPLETED', |
| 176 'result': 'SUCCESS', | 167 'result': 'SUCCESS', |
| 177 'url': 'http://build.chromium.org/p/master/builders/some-builder
/builds/123', | 168 'url': 'http://build.chromium.org/p/master/builders/some-builder
/builds/123', |
| 178 }, | 169 }, |
| 179 ] | 170 ] |
| 180 self.assertEqual( | 171 self.assertEqual( |
| 181 git_cl.latest_try_jobs(['builder-a', 'builder-b']), | 172 git_cl.latest_try_jobs(['builder-a', 'builder-b']), |
| 182 [Build('builder-a'), Build('builder-b', 100)]) | 173 [Build('builder-a'), Build('builder-b', 100)]) |
| OLD | NEW |