| 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 os |    8 import os | 
|    9 import StringIO |    9 import StringIO | 
|   10 import stat |   10 import stat | 
| (...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  404     def ParseCodereviewSettingsContent(content): |  404     def ParseCodereviewSettingsContent(content): | 
|  405       keyvals = {} |  405       keyvals = {} | 
|  406       keyvals['CODE_REVIEW_SERVER'] = 'gerrit.chromium.org' |  406       keyvals['CODE_REVIEW_SERVER'] = 'gerrit.chromium.org' | 
|  407       keyvals['GERRIT_HOST'] = 'gerrit.chromium.org' |  407       keyvals['GERRIT_HOST'] = 'gerrit.chromium.org' | 
|  408       keyvals['GERRIT_PORT'] = '29418' |  408       keyvals['GERRIT_PORT'] = '29418' | 
|  409       return keyvals |  409       return keyvals | 
|  410     self.mock(git_cl.gclient_utils, 'ParseCodereviewSettingsContent', |  410     self.mock(git_cl.gclient_utils, 'ParseCodereviewSettingsContent', | 
|  411               ParseCodereviewSettingsContent) |  411               ParseCodereviewSettingsContent) | 
|  412     self.mock(git_cl.os, 'access', self._mocked_call) |  412     self.mock(git_cl.os, 'access', self._mocked_call) | 
|  413     self.mock(git_cl.os, 'chmod', self._mocked_call) |  413     self.mock(git_cl.os, 'chmod', self._mocked_call) | 
 |  414     src_dir = os.path.join(os.path.sep, 'usr', 'local', 'src') | 
|  414     def AbsPath(path): |  415     def AbsPath(path): | 
|  415       if not path.startswith('/'): |  416       if not path.startswith(os.path.sep): | 
|  416         return os.path.join('/usr/local/src', path) |  417         return os.path.join(src_dir, path) | 
|  417       return path |  418       return path | 
|  418     self.mock(git_cl.os.path, 'abspath', AbsPath) |  419     self.mock(git_cl.os.path, 'abspath', AbsPath) | 
 |  420     commit_msg_path = os.path.join(src_dir, '.git', 'hooks', 'commit-msg') | 
|  419     def Exists(path): |  421     def Exists(path): | 
|  420       if path == '/usr/local/src/.git/hooks/commit-msg': |  422       if path == commit_msg_path: | 
|  421         return False |  423         return False | 
|  422       # others paths, such as /usr/share/locale/.... |  424       # others paths, such as /usr/share/locale/.... | 
|  423       return True |  425       return True | 
|  424     self.mock(git_cl.os.path, 'exists', Exists) |  426     self.mock(git_cl.os.path, 'exists', Exists) | 
|  425     self.mock(git_cl.urllib, 'urlretrieve', self._mocked_call) |  427     self.mock(git_cl.urllib, 'urlretrieve', self._mocked_call) | 
|  426     self.calls = [ |  428     self.calls = [ | 
|  427         ((['git', 'config', 'rietveld.server', 'gerrit.chromium.org'],), ''), |  429         ((['git', 'config', 'rietveld.server', 'gerrit.chromium.org'],), ''), | 
|  428         ((['git', 'config', '--unset-all', 'rietveld.cc'],), ''), |  430         ((['git', 'config', '--unset-all', 'rietveld.cc'],), ''), | 
|  429         ((['git', 'config', '--unset-all', 'rietveld.tree-status-url'],), ''), |  431         ((['git', 'config', '--unset-all', 'rietveld.tree-status-url'],), ''), | 
|  430         ((['git', 'config', '--unset-all', 'rietveld.viewvc-url'],), ''), |  432         ((['git', 'config', '--unset-all', 'rietveld.viewvc-url'],), ''), | 
|  431         ((['git', 'config', 'gerrit.host', 'gerrit.chromium.org'],), ''), |  433         ((['git', 'config', 'gerrit.host', 'gerrit.chromium.org'],), ''), | 
|  432         ((['git', 'config', 'gerrit.port', '29418'],), ''), |  434         ((['git', 'config', 'gerrit.port', '29418'],), ''), | 
|  433         # DownloadHooks(False) |  435         # DownloadHooks(False) | 
|  434         ((['git', 'config', 'gerrit.host'],), 'gerrit.chromium.org'), |  436         ((['git', 'config', 'gerrit.host'],), 'gerrit.chromium.org'), | 
|  435         ((['git', 'config', 'rietveld.server'],), 'gerrit.chromium.org'), |  437         ((['git', 'config', 'rietveld.server'],), 'gerrit.chromium.org'), | 
|  436         ((['git', 'rev-parse', '--show-cdup'],), ''), |  438         ((['git', 'rev-parse', '--show-cdup'],), ''), | 
|  437         (('/usr/local/src/.git/hooks/commit-msg', os.X_OK,), False), |  439         ((commit_msg_path, os.X_OK,), False), | 
|  438         (('https://gerrit.chromium.org/tools/hooks/commit-msg', |  440         (('https://gerrit.chromium.org/tools/hooks/commit-msg', | 
|  439           '/usr/local/src/.git/hooks/commit-msg',), ''), |  441           commit_msg_path,), ''), | 
|  440         (('/usr/local/src/.git/hooks/commit-msg', |  442         ((commit_msg_path, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR,), ''), | 
|  441           stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR,), ''), |  | 
|  442         # GetCodereviewSettingsInteractively |  443         # GetCodereviewSettingsInteractively | 
|  443         ((['git', 'config', 'rietveld.server'],), 'gerrit.chromium.org'), |  444         ((['git', 'config', 'rietveld.server'],), 'gerrit.chromium.org'), | 
|  444         (('Rietveld server (host[:port]) [https://gerrit.chromium.org]:',), |  445         (('Rietveld server (host[:port]) [https://gerrit.chromium.org]:',), | 
|  445          ''), |  446          ''), | 
|  446         ((['git', 'config', 'rietveld.cc'],), ''), |  447         ((['git', 'config', 'rietveld.cc'],), ''), | 
|  447         (('CC list:',), ''), |  448         (('CC list:',), ''), | 
|  448         ((['git', 'config', 'rietveld.tree-status-url'],), ''), |  449         ((['git', 'config', 'rietveld.tree-status-url'],), ''), | 
|  449         (('Tree status URL:',), ''), |  450         (('Tree status URL:',), ''), | 
|  450         ((['git', 'config', 'rietveld.viewvc-url'],), ''), |  451         ((['git', 'config', 'rietveld.viewvc-url'],), ''), | 
|  451         (('ViewVC URL:',), ''), |  452         (('ViewVC URL:',), ''), | 
|  452         # DownloadHooks(True) |  453         # DownloadHooks(True) | 
|  453         (('/usr/local/src/.git/hooks/commit-msg', os.X_OK,), True), |  454         ((commit_msg_path, os.X_OK,), True), | 
|  454         ] |  455         ] | 
|  455     git_cl.main(['config']) |  456     git_cl.main(['config']) | 
|  456  |  457  | 
|  457  |  458  | 
|  458 if __name__ == '__main__': |  459 if __name__ == '__main__': | 
|  459   unittest.main() |  460   unittest.main() | 
| OLD | NEW |