Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(119)

Unified Diff: tests/git_cl_test.py

Issue 9369023: Download hooks only in "git cl config" (Closed) Base URL: svn://chrome-svn/chrome/trunk/tools/depot_tools/
Patch Set: '' Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « git_cl.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/git_cl_test.py
===================================================================
--- tests/git_cl_test.py (revision 121410)
+++ tests/git_cl_test.py (working copy)
@@ -7,6 +7,7 @@
import os
import StringIO
+import stat
import sys
import unittest
@@ -42,6 +43,15 @@
return ['joe@example.com']
+class CodereviewSettingsFileMock(object):
+ def __init__(self):
+ pass
+ def read(self):
Marc-Antoine Ruel (Google) 2012/02/13 20:47:52 You can disable the warning at file level. It's no
+ return ("CODE_REVIEW_SERVER: gerrit.chromium.org\n" +
+ "GERRIT_HOST: gerrit.chromium.org\n" +
+ "GERRIT_PORT: 29418\n")
+
+
class TestGitCl(TestCase):
def setUp(self):
super(TestGitCl, self).setUp()
@@ -393,5 +403,61 @@
['reviewer@example.com', 'another@example.com'])
+ def test_config_gerrit_download_hook(self):
+ self.mock(git_cl, 'FindCodereviewSettingsFile', CodereviewSettingsFileMock)
+ def ParseCodereviewSettingsContent(content):
+ keyvals = {}
+ keyvals['CODE_REVIEW_SERVER'] = 'gerrit.chromium.org'
+ keyvals['GERRIT_HOST'] = 'gerrit.chromium.org'
+ keyvals['GERRIT_PORT'] = '29418'
+ return keyvals
+ self.mock(git_cl.gclient_utils, 'ParseCodereviewSettingsContent',
+ ParseCodereviewSettingsContent)
+ self.mock(git_cl.os, 'access', self._mocked_call)
+ self.mock(git_cl.os, 'chmod', self._mocked_call)
+ def AbsPath(path):
+ if not path.startswith('/'):
+ return os.path.join('/usr/local/src', path)
+ return path
+ self.mock(git_cl.os.path, 'abspath', AbsPath)
+ def Exists(path):
+ if path == '/usr/local/src/.git/hooks/commit-msg':
+ return False
+ # others paths, such as /usr/share/locale/....
+ return True
+ self.mock(git_cl.os.path, 'exists', Exists)
+ self.mock(git_cl.urllib, 'urlretrieve', self._mocked_call)
+ self.calls = [
+ ((['git', 'config', 'rietveld.server', 'gerrit.chromium.org'],), ''),
+ ((['git', 'config', '--unset-all', 'rietveld.cc'],), ''),
+ ((['git', 'config', '--unset-all', 'rietveld.tree-status-url'],), ''),
+ ((['git', 'config', '--unset-all', 'rietveld.viewvc-url'],), ''),
+ ((['git', 'config', 'gerrit.host', 'gerrit.chromium.org'],), ''),
+ ((['git', 'config', 'gerrit.port', '29418'],), ''),
+ # DownloadHooks(False)
+ ((['git', 'config', 'gerrit.host'],), 'gerrit.chromium.org'),
+ ((['git', 'config', 'rietveld.server'],), 'gerrit.chromium.org'),
+ ((['git', 'rev-parse', '--show-cdup'],), ''),
+ (('/usr/local/src/.git/hooks/commit-msg', os.X_OK,), False),
+ (('https://gerrit.chromium.org/tools/hooks/commit-msg',
+ '/usr/local/src/.git/hooks/commit-msg',), ''),
+ (('/usr/local/src/.git/hooks/commit-msg',
+ stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR,), ''),
+ # GetCodereviewSettingsInteractively
+ ((['git', 'config', 'rietveld.server'],), 'gerrit.chromium.org'),
+ (('Rietveld server (host[:port]) [https://gerrit.chromium.org]:',),
+ ''),
+ ((['git', 'config', 'rietveld.cc'],), ''),
+ (('CC list:',), ''),
+ ((['git', 'config', 'rietveld.tree-status-url'],), ''),
+ (('Tree status URL:',), ''),
+ ((['git', 'config', 'rietveld.viewvc-url'],), ''),
+ (('ViewVC URL:',), ''),
+ # DownloadHooks(True)
+ (('/usr/local/src/.git/hooks/commit-msg', os.X_OK,), True),
+ ]
+ git_cl.main(['config'])
+
+
if __name__ == '__main__':
unittest.main()
« no previous file with comments | « git_cl.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698