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 gclient_scm.py.""" | 6 """Unit tests for gclient_scm.py.""" |
7 | 7 |
8 # pylint: disable=E1103 | 8 # pylint: disable=E1103 |
9 | 9 |
10 # Import before super_mox to keep valid references. | 10 # Import before super_mox to keep valid references. |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
81 gclient_scm.GitWrapper.BinaryExists = staticmethod(lambda : True) | 81 gclient_scm.GitWrapper.BinaryExists = staticmethod(lambda : True) |
82 # Absolute path of the fake checkout directory. | 82 # Absolute path of the fake checkout directory. |
83 self.base_path = join(self.root_dir, self.relpath) | 83 self.base_path = join(self.root_dir, self.relpath) |
84 | 84 |
85 def tearDown(self): | 85 def tearDown(self): |
86 SuperMoxTestBase.tearDown(self) | 86 SuperMoxTestBase.tearDown(self) |
87 gclient_scm.SVNWrapper.BinaryExists = self._original_SVNBinaryExists | 87 gclient_scm.SVNWrapper.BinaryExists = self._original_SVNBinaryExists |
88 gclient_scm.GitWrapper.BinaryExists = self._original_GitBinaryExists | 88 gclient_scm.GitWrapper.BinaryExists = self._original_GitBinaryExists |
89 | 89 |
90 | 90 |
91 class BasicTests(SuperMoxTestBase): | |
92 def setUp(self): | |
93 SuperMoxTestBase.setUp(self) | |
94 | |
95 def testGetFirstRemoteUrl(self): | |
96 REMOTE_STRINGS = [('remote.origin.url E:\\foo\\bar', 'E:\\foo\\bar'), | |
iannucci
2014/08/22 17:43:46
oh, can you do one with quotes? I think that's wha
| |
97 ('remote.origin.url /b/foo/bar', '/b/foo/bar'), | |
98 ('remote.origin.url https://foo/bar', 'https://foo/bar')] | |
99 FAKE_PATH = '/fake/path' | |
100 self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'Capture') | |
101 for question, _ in REMOTE_STRINGS: | |
102 gclient_scm.scm.GIT.Capture( | |
103 ['config', '--local', '--get-regexp', r'remote.*.url'], | |
104 cwd=FAKE_PATH).AndReturn(question) | |
105 | |
106 self.mox.ReplayAll() | |
107 | |
108 for _, answer in REMOTE_STRINGS: | |
109 self.assertEquals(gclient_scm.SCMWrapper._get_first_remote_url(FAKE_PATH), | |
110 answer) | |
111 | |
112 def tearDown(self): | |
113 SuperMoxTestBase.tearDown(self) | |
114 | |
115 | |
91 class SVNWrapperTestCase(BaseTestCase): | 116 class SVNWrapperTestCase(BaseTestCase): |
92 class OptionsObject(object): | 117 class OptionsObject(object): |
93 def __init__(self, verbose=False, revision=None, force=False): | 118 def __init__(self, verbose=False, revision=None, force=False): |
94 self.verbose = verbose | 119 self.verbose = verbose |
95 self.revision = revision | 120 self.revision = revision |
96 self.manually_grab_svn_rev = True | 121 self.manually_grab_svn_rev = True |
97 self.deps_os = None | 122 self.deps_os = None |
98 self.force = force | 123 self.force = force |
99 self.reset = False | 124 self.reset = False |
100 self.nohooks = False | 125 self.nohooks = False |
(...skipping 1482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1583 | 1608 |
1584 if __name__ == '__main__': | 1609 if __name__ == '__main__': |
1585 level = logging.DEBUG if '-v' in sys.argv else logging.FATAL | 1610 level = logging.DEBUG if '-v' in sys.argv else logging.FATAL |
1586 logging.basicConfig( | 1611 logging.basicConfig( |
1587 level=level, | 1612 level=level, |
1588 format='%(asctime).19s %(levelname)s %(filename)s:' | 1613 format='%(asctime).19s %(levelname)s %(filename)s:' |
1589 '%(lineno)s %(message)s') | 1614 '%(lineno)s %(message)s') |
1590 unittest.main() | 1615 unittest.main() |
1591 | 1616 |
1592 # vim: ts=2:sw=2:tw=80:et: | 1617 # vim: ts=2:sw=2:tw=80:et: |
OLD | NEW |