| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2006-2009 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 scm.py.""" | 6 """Unit tests for scm.py.""" |
| 7 | 7 |
| 8 import shutil | 8 import shutil |
| 9 import tempfile | 9 import tempfile |
| 10 | 10 |
| 11 from gclient_test import BaseTestCase | 11 from gclient_test import BaseTestCase |
| 12 import scm | 12 import scm |
| 13 from super_mox import mox, SuperMoxBaseTestBase | 13 from super_mox import mox, SuperMoxBaseTestBase |
| 14 | 14 |
| 15 | 15 |
| 16 class BaseSCMTestCase(BaseTestCase): | 16 class BaseSCMTestCase(BaseTestCase): |
| 17 def setUp(self): | 17 def setUp(self): |
| 18 BaseTestCase.setUp(self) | 18 BaseTestCase.setUp(self) |
| 19 self.mox.StubOutWithMock(scm.gclient_utils, 'SubprocessCall') | 19 self.mox.StubOutWithMock(scm.gclient_utils, 'SubprocessCall') |
| 20 self.mox.StubOutWithMock(scm.gclient_utils, 'SubprocessCallAndFilter') | 20 self.mox.StubOutWithMock(scm.gclient_utils, 'SubprocessCallAndFilter') |
| 21 | 21 |
| 22 | 22 |
| 23 class RootTestCase(BaseSCMTestCase): | 23 class RootTestCase(BaseSCMTestCase): |
| 24 def testMembersChanged(self): | 24 def testMembersChanged(self): |
| 25 self.mox.ReplayAll() | 25 self.mox.ReplayAll() |
| 26 members = [ | 26 members = [ |
| 27 'GIT', 'SVN', 'ValidateEmail', | 27 'GetCasedPath', 'GIT', 'SVN', 'ValidateEmail', |
| 28 'gclient_utils', 'os', 're', 'shutil', 'subprocess', 'sys', 'tempfile', | 28 'gclient_utils', 'glob', 'os', 're', 'shutil', 'subprocess', 'sys', |
| 29 'xml', | 29 'tempfile', 'xml', |
| 30 ] | 30 ] |
| 31 # If this test fails, you should add the relevant test. | 31 # If this test fails, you should add the relevant test. |
| 32 self.compareMembers(scm, members) | 32 self.compareMembers(scm, members) |
| 33 | 33 |
| 34 | 34 |
| 35 class GitWrapperTestCase(SuperMoxBaseTestBase): | 35 class GitWrapperTestCase(SuperMoxBaseTestBase): |
| 36 sample_git_import = """blob | 36 sample_git_import = """blob |
| 37 mark :1 | 37 mark :1 |
| 38 data 6 | 38 data 6 |
| 39 Hello | 39 Hello |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 'COMMAND', 'Capture', 'CaptureHeadRevision', 'CaptureInfo', | 146 'COMMAND', 'Capture', 'CaptureHeadRevision', 'CaptureInfo', |
| 147 'CaptureStatus', 'DiffItem', 'GenerateDiff', 'GetCheckoutRoot', | 147 'CaptureStatus', 'DiffItem', 'GenerateDiff', 'GetCheckoutRoot', |
| 148 'GetEmail', 'GetFileProperty', 'IsMoved', | 148 'GetEmail', 'GetFileProperty', 'IsMoved', |
| 149 'ReadSimpleAuth', 'Run', 'RunAndFilterOutput', 'RunAndGetFileList', | 149 'ReadSimpleAuth', 'Run', 'RunAndFilterOutput', 'RunAndGetFileList', |
| 150 ] | 150 ] |
| 151 # If this test fails, you should add the relevant test. | 151 # If this test fails, you should add the relevant test. |
| 152 self.compareMembers(scm.SVN, members) | 152 self.compareMembers(scm.SVN, members) |
| 153 | 153 |
| 154 def testGetCheckoutRoot(self): | 154 def testGetCheckoutRoot(self): |
| 155 self.mox.StubOutWithMock(scm.SVN, 'CaptureInfo') | 155 self.mox.StubOutWithMock(scm.SVN, 'CaptureInfo') |
| 156 self.mox.StubOutWithMock(scm, 'GetCasedPath') |
| 156 scm.os.path.abspath(self.root_dir + 'x').AndReturn(self.root_dir) | 157 scm.os.path.abspath(self.root_dir + 'x').AndReturn(self.root_dir) |
| 158 scm.GetCasedPath(self.root_dir).AndReturn(self.root_dir) |
| 157 result1 = { "Repository Root": "Some root" } | 159 result1 = { "Repository Root": "Some root" } |
| 158 scm.SVN.CaptureInfo(self.root_dir, print_error=False).AndReturn(result1) | 160 scm.SVN.CaptureInfo(self.root_dir, print_error=False).AndReturn(result1) |
| 159 results2 = { "Repository Root": "A different root" } | 161 results2 = { "Repository Root": "A different root" } |
| 160 scm.SVN.CaptureInfo(scm.os.path.dirname(self.root_dir), | 162 scm.SVN.CaptureInfo(scm.os.path.dirname(self.root_dir), |
| 161 print_error=False).AndReturn(results2) | 163 print_error=False).AndReturn(results2) |
| 162 self.mox.ReplayAll() | 164 self.mox.ReplayAll() |
| 163 self.assertEquals(scm.SVN.GetCheckoutRoot(self.root_dir + 'x'), | 165 self.assertEquals(scm.SVN.GetCheckoutRoot(self.root_dir + 'x'), |
| 164 self.root_dir) | 166 self.root_dir) |
| 165 | 167 |
| 166 def testGetFileInfo(self): | 168 def testGetFileInfo(self): |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 self.mox.ReplayAll() | 321 self.mox.ReplayAll() |
| 320 info = scm.SVN.CaptureStatus(None) | 322 info = scm.SVN.CaptureStatus(None) |
| 321 self.assertEquals(info, []) | 323 self.assertEquals(info, []) |
| 322 | 324 |
| 323 | 325 |
| 324 if __name__ == '__main__': | 326 if __name__ == '__main__': |
| 325 import unittest | 327 import unittest |
| 326 unittest.main() | 328 unittest.main() |
| 327 | 329 |
| 328 # vim: ts=2:sw=2:tw=80:et: | 330 # vim: ts=2:sw=2:tw=80:et: |
| OLD | NEW |