| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Copyright (c) 2010 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2010 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 from shutil import rmtree | 8 from shutil import rmtree |
| 9 import tempfile | 9 import tempfile |
| 10 | 10 |
| 11 # Fixes include path. | 11 # Fixes include path. |
| 12 from super_mox import mox, SuperMoxBaseTestBase | 12 from super_mox import mox, SuperMoxBaseTestBase |
| 13 | 13 |
| 14 from gclient_test import BaseTestCase | 14 from gclient_test import BaseTestCase |
| 15 import scm | 15 import scm |
| 16 | 16 |
| 17 | 17 |
| 18 class BaseSCMTestCase(BaseTestCase): | 18 class BaseSCMTestCase(BaseTestCase): |
| 19 def setUp(self): | 19 def setUp(self): |
| 20 BaseTestCase.setUp(self) | 20 BaseTestCase.setUp(self) |
| 21 self.mox.StubOutWithMock(scm.gclient_utils, 'SubprocessCall') | 21 self.mox.StubOutWithMock(scm.gclient_utils, 'SubprocessCall') |
| 22 self.mox.StubOutWithMock(scm.gclient_utils, 'SubprocessCallAndFilter') | 22 self.mox.StubOutWithMock(scm.gclient_utils, 'SubprocessCallAndFilter') |
| 23 | 23 |
| 24 | 24 |
| 25 class RootTestCase(BaseSCMTestCase): | 25 class RootTestCase(BaseSCMTestCase): |
| 26 def testMembersChanged(self): | 26 def testMembersChanged(self): |
| 27 self.mox.ReplayAll() | 27 self.mox.ReplayAll() |
| 28 members = [ | 28 members = [ |
| 29 'GetCasedPath', 'GIT', 'SVN', 'ValidateEmail', | 29 'GetCasedPath', 'GenFakeDiff', 'GIT', 'SVN', 'ValidateEmail', |
| 30 'gclient_utils', 'glob', 'os', 're', 'shutil', 'subprocess', 'sys', | 30 'cStringIO', 'gclient_utils', 'glob', 'os', 're', 'shutil', |
| 31 'tempfile', 'time', 'xml', | 31 'subprocess', 'sys', 'tempfile', 'time', 'xml', |
| 32 ] | 32 ] |
| 33 # If this test fails, you should add the relevant test. | 33 # If this test fails, you should add the relevant test. |
| 34 self.compareMembers(scm, members) | 34 self.compareMembers(scm, members) |
| 35 | 35 |
| 36 | 36 |
| 37 class GitWrapperTestCase(SuperMoxBaseTestBase): | 37 class GitWrapperTestCase(SuperMoxBaseTestBase): |
| 38 sample_git_import = """blob | 38 sample_git_import = """blob |
| 39 mark :1 | 39 mark :1 |
| 40 data 6 | 40 data 6 |
| 41 Hello | 41 Hello |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 self.root_dir = self.Dir() | 142 self.root_dir = self.Dir() |
| 143 self.args = self.Args() | 143 self.args = self.Args() |
| 144 self.url = self.Url() | 144 self.url = self.Url() |
| 145 self.relpath = 'asf' | 145 self.relpath = 'asf' |
| 146 | 146 |
| 147 def testMembersChanged(self): | 147 def testMembersChanged(self): |
| 148 self.mox.ReplayAll() | 148 self.mox.ReplayAll() |
| 149 members = [ | 149 members = [ |
| 150 'COMMAND', 'AssertVersion', 'Capture', 'CaptureBaseRevision', | 150 'COMMAND', 'AssertVersion', 'Capture', 'CaptureBaseRevision', |
| 151 'CaptureHeadRevision', 'CaptureInfo', 'CaptureStatus', | 151 'CaptureHeadRevision', 'CaptureInfo', 'CaptureStatus', |
| 152 'current_version', 'DiffItem', 'GenerateDiff', 'GetCheckoutRoot', | 152 'current_version', 'DiffItem', 'GenerateDiff', |
| 153 'GetEmail', 'GetFileProperty', 'IsMoved', 'ReadSimpleAuth', 'Run', | 153 'GetCheckoutRoot', 'GetEmail', 'GetFileProperty', 'IsMoved', |
| 154 'RunAndFilterOutput', 'RunAndGetFileList', | 154 'IsMovedInfo', 'ReadSimpleAuth', 'Run', 'RunAndFilterOutput', |
| 155 'RunAndGetFileList', |
| 155 ] | 156 ] |
| 156 # If this test fails, you should add the relevant test. | 157 # If this test fails, you should add the relevant test. |
| 157 self.compareMembers(scm.SVN, members) | 158 self.compareMembers(scm.SVN, members) |
| 158 | 159 |
| 159 def testGetCheckoutRoot(self): | 160 def testGetCheckoutRoot(self): |
| 160 self.mox.StubOutWithMock(scm.SVN, 'CaptureInfo') | 161 self.mox.StubOutWithMock(scm.SVN, 'CaptureInfo') |
| 161 self.mox.StubOutWithMock(scm, 'GetCasedPath') | 162 self.mox.StubOutWithMock(scm, 'GetCasedPath') |
| 162 scm.os.path.abspath(self.root_dir + 'x').AndReturn(self.root_dir) | 163 scm.os.path.abspath(self.root_dir + 'x').AndReturn(self.root_dir) |
| 163 scm.GetCasedPath(self.root_dir).AndReturn(self.root_dir) | 164 scm.GetCasedPath(self.root_dir).AndReturn(self.root_dir) |
| 164 result1 = { "Repository Root": "Some root" } | 165 result1 = { "Repository Root": "Some root" } |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 self.mox.ReplayAll() | 327 self.mox.ReplayAll() |
| 327 info = scm.SVN.CaptureStatus(None) | 328 info = scm.SVN.CaptureStatus(None) |
| 328 self.assertEquals(info, []) | 329 self.assertEquals(info, []) |
| 329 | 330 |
| 330 | 331 |
| 331 if __name__ == '__main__': | 332 if __name__ == '__main__': |
| 332 import unittest | 333 import unittest |
| 333 unittest.main() | 334 unittest.main() |
| 334 | 335 |
| 335 # vim: ts=2:sw=2:tw=80:et: | 336 # vim: ts=2:sw=2:tw=80:et: |
| OLD | NEW |