Commit 125d60a1 authored by Edward Lemur's avatar Edward Lemur Committed by Commit Bot

git-cl: Remove ChangeListImplementation boilerplate.

Change-Id: I880c60e4b4e07fdb68a63af8d7a171d54371ee71
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1802294
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
Reviewed-by: 's avatarAndrii Shyshkalov <tandrii@google.com>
parent 5b6ae8bc
This diff is collapsed.
...@@ -157,7 +157,7 @@ class TestGitClBasic(unittest.TestCase): ...@@ -157,7 +157,7 @@ class TestGitClBasic(unittest.TestCase):
cl = git_cl.Changelist(issue=1, codereview_host='host') cl = git_cl.Changelist(issue=1, codereview_host='host')
cl.description = 'x' cl.description = 'x'
cl.has_description = True cl.has_description = True
cl._codereview_impl.FetchDescription = lambda *a, **kw: 'y' cl.FetchDescription = lambda *a, **kw: 'y'
self.assertEquals(cl.GetDescription(), 'x') self.assertEquals(cl.GetDescription(), 'x')
self.assertEquals(cl.GetDescription(force=True), 'y') self.assertEquals(cl.GetDescription(force=True), 'y')
self.assertEquals(cl.GetDescription(), 'y') self.assertEquals(cl.GetDescription(), 'y')
...@@ -174,7 +174,7 @@ class TestGitClBasic(unittest.TestCase): ...@@ -174,7 +174,7 @@ class TestGitClBasic(unittest.TestCase):
'Awesome: Footers', 'Awesome: Footers',
]) ])
cl.has_description = True cl.has_description = True
cl._codereview_impl.UpdateDescriptionRemote = lambda *a, **kw: 'y' cl.UpdateDescriptionRemote = lambda *a, **kw: 'y'
msg, footers = cl.GetDescriptionFooters() msg, footers = cl.GetDescriptionFooters()
self.assertEquals( self.assertEquals(
msg, ['This is some message', '', 'It has some lines', 'and, also']) msg, ['This is some message', '', 'It has some lines', 'and, also'])
...@@ -489,7 +489,7 @@ class TestParseIssueURL(unittest.TestCase): ...@@ -489,7 +489,7 @@ class TestParseIssueURL(unittest.TestCase):
def test_gerrit(self): def test_gerrit(self):
def test(url, *args, **kwargs): def test(url, *args, **kwargs):
self._run_and_validate(git_cl._GerritChangelistImpl.ParseIssueURL, url, self._run_and_validate(git_cl.Changelist.ParseIssueURL, url,
*args, **kwargs) *args, **kwargs)
test('http://chrome-review.source.com/c/123', test('http://chrome-review.source.com/c/123',
...@@ -1253,7 +1253,7 @@ class TestGitCl(TestCase): ...@@ -1253,7 +1253,7 @@ class TestGitCl(TestCase):
self.mock(git_cl.gerrit_util, 'CookiesAuthenticator', self.mock(git_cl.gerrit_util, 'CookiesAuthenticator',
CookiesAuthenticatorMockFactory( CookiesAuthenticatorMockFactory(
same_auth=('git-owner.example.com', '', 'pass'))) same_auth=('git-owner.example.com', '', 'pass')))
self.mock(git_cl._GerritChangelistImpl, '_GerritCommitMsgHookCheck', self.mock(git_cl.Changelist, '_GerritCommitMsgHookCheck',
lambda _, offer_removal: None) lambda _, offer_removal: None)
self.mock(git_cl.gclient_utils, 'RunEditor', self.mock(git_cl.gclient_utils, 'RunEditor',
lambda *_, **__: self._mocked_call(['RunEditor'])) lambda *_, **__: self._mocked_call(['RunEditor']))
...@@ -1724,7 +1724,7 @@ class TestGitCl(TestCase): ...@@ -1724,7 +1724,7 @@ class TestGitCl(TestCase):
git_short_host='host', git_short_host='host',
detect_branch=True, detect_branch=True,
detect_server=True): detect_server=True):
"""Returns calls executed by _GerritChangelistImpl.GetCodereviewServer. """Returns calls executed by Changelist.GetCodereviewServer.
If value is given, branch.<BRANCH>.gerritcodereview is already set. If value is given, branch.<BRANCH>.gerritcodereview is already set.
""" """
...@@ -2177,7 +2177,7 @@ class TestGitCl(TestCase): ...@@ -2177,7 +2177,7 @@ class TestGitCl(TestCase):
self.mock(git_cl.sys, 'stdout', StringIO.StringIO()) self.mock(git_cl.sys, 'stdout', StringIO.StringIO())
self.mock(git_cl.Changelist, 'GetDescription', self.mock(git_cl.Changelist, 'GetDescription',
lambda *args: current_desc) lambda *args: current_desc)
self.mock(git_cl._GerritChangelistImpl, 'UpdateDescriptionRemote', self.mock(git_cl.Changelist, 'UpdateDescriptionRemote',
UpdateDescriptionRemote) UpdateDescriptionRemote)
self.mock(git_cl.gclient_utils, 'RunEditor', RunEditor) self.mock(git_cl.gclient_utils, 'RunEditor', RunEditor)
...@@ -2328,7 +2328,7 @@ class TestGitCl(TestCase): ...@@ -2328,7 +2328,7 @@ class TestGitCl(TestCase):
self.mock(git_cl.presubmit_support, 'DoGetTryMasters', self.mock(git_cl.presubmit_support, 'DoGetTryMasters',
lambda *_, **__: ( lambda *_, **__: (
self._mocked_call(['DoGetTryMasters']))) self._mocked_call(['DoGetTryMasters'])))
self.mock(git_cl._GerritChangelistImpl, 'SetCQState', self.mock(git_cl.Changelist, 'SetCQState',
lambda _, s: self._mocked_call(['SetCQState', s])) lambda _, s: self._mocked_call(['SetCQState', s]))
self.calls = [ self.calls = [
...@@ -2368,7 +2368,7 @@ class TestGitCl(TestCase): ...@@ -2368,7 +2368,7 @@ class TestGitCl(TestCase):
'', '', '', '', '', '', '', '')), '', '', '', '', '', '', '', '')),
((['git', 'rev-parse', '--show-cdup'],), '../'), ((['git', 'rev-parse', '--show-cdup'],), '../'),
((['DoGetTryMasters'], ), None), ((['DoGetTryMasters'], ), None),
((['SetCQState', git_cl._CQState.DRY_RUN], ), None), ((['SetCQState', git_cl._CQState.DRY_RUN], ), 0),
] ]
out = StringIO.StringIO() out = StringIO.StringIO()
self.mock(git_cl.sys, 'stdout', out) self.mock(git_cl.sys, 'stdout', out)
...@@ -2483,14 +2483,14 @@ class TestGitCl(TestCase): ...@@ -2483,14 +2483,14 @@ class TestGitCl(TestCase):
((['FileRead', '/abs/git_repo_root/.git/hooks/commit-msg'],), ((['FileRead', '/abs/git_repo_root/.git/hooks/commit-msg'],),
'#!/bin/sh\necho "custom hook"') '#!/bin/sh\necho "custom hook"')
] ]
cl._codereview_impl._GerritCommitMsgHookCheck(offer_removal=True) cl._GerritCommitMsgHookCheck(offer_removal=True)
def test_GerritCommitMsgHookCheck_not_exists(self): def test_GerritCommitMsgHookCheck_not_exists(self):
cl = self._common_GerritCommitMsgHookCheck() cl = self._common_GerritCommitMsgHookCheck()
self.calls += [ self.calls += [
((['exists', '/abs/git_repo_root/.git/hooks/commit-msg'],), False), ((['exists', '/abs/git_repo_root/.git/hooks/commit-msg'],), False),
] ]
cl._codereview_impl._GerritCommitMsgHookCheck(offer_removal=True) cl._GerritCommitMsgHookCheck(offer_removal=True)
def test_GerritCommitMsgHookCheck(self): def test_GerritCommitMsgHookCheck(self):
cl = self._common_GerritCommitMsgHookCheck() cl = self._common_GerritCommitMsgHookCheck()
...@@ -2502,7 +2502,7 @@ class TestGitCl(TestCase): ...@@ -2502,7 +2502,7 @@ class TestGitCl(TestCase):
((['rm_file_or_tree', '/abs/git_repo_root/.git/hooks/commit-msg'],), ((['rm_file_or_tree', '/abs/git_repo_root/.git/hooks/commit-msg'],),
''), ''),
] ]
cl._codereview_impl._GerritCommitMsgHookCheck(offer_removal=True) cl._GerritCommitMsgHookCheck(offer_removal=True)
def test_GerritCmdLand(self): def test_GerritCmdLand(self):
self.calls += [ self.calls += [
...@@ -2514,16 +2514,16 @@ class TestGitCl(TestCase): ...@@ -2514,16 +2514,16 @@ class TestGitCl(TestCase):
'chromium-review.googlesource.com'), 'chromium-review.googlesource.com'),
] ]
cl = git_cl.Changelist(issue=123) cl = git_cl.Changelist(issue=123)
cl._codereview_impl._GetChangeDetail = lambda _: { cl._GetChangeDetail = lambda *args, **kwargs: {
'labels': {}, 'labels': {},
'current_revision': 'deadbeaf', 'current_revision': 'deadbeaf',
} }
cl._codereview_impl._GetChangeCommit = lambda: { cl._GetChangeCommit = lambda: {
'commit': 'deadbeef', 'commit': 'deadbeef',
'web_links': [{'name': 'gitiles', 'web_links': [{'name': 'gitiles',
'url': 'https://git.googlesource.com/test/+/deadbeef'}], 'url': 'https://git.googlesource.com/test/+/deadbeef'}],
} }
cl._codereview_impl.SubmitIssue = lambda wait_for_merge: None cl.SubmitIssue = lambda wait_for_merge: None
out = StringIO.StringIO() out = StringIO.StringIO()
self.mock(sys, 'stdout', out) self.mock(sys, 'stdout', out)
self.assertEqual(0, cl.CMDLand(force=True, self.assertEqual(0, cl.CMDLand(force=True,
...@@ -2671,7 +2671,7 @@ class TestGitCl(TestCase): ...@@ -2671,7 +2671,7 @@ class TestGitCl(TestCase):
self.assertRegexpMatches(sys.stdout.getvalue(), '2 tryjobs') self.assertRegexpMatches(sys.stdout.getvalue(), '2 tryjobs')
def _mock_gerrit_changes_for_detail_cache(self): def _mock_gerrit_changes_for_detail_cache(self):
self.mock(git_cl._GerritChangelistImpl, '_GetGerritHost', lambda _: 'host') self.mock(git_cl.Changelist, '_GetGerritHost', lambda _: 'host')
def test_gerrit_change_detail_cache_simple(self): def test_gerrit_change_detail_cache_simple(self):
self._mock_gerrit_changes_for_detail_cache() self._mock_gerrit_changes_for_detail_cache()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment