OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2011 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 # pylint: disable=E1101,W0403 | |
9 from __future__ import with_statement | 8 from __future__ import with_statement |
10 import logging | 9 import logging |
| 10 import os |
11 import sys | 11 import sys |
12 import unittest | 12 import unittest |
13 | 13 |
14 # Fixes include path. | 14 sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) |
| 15 |
15 from super_mox import SuperMoxTestBase | 16 from super_mox import SuperMoxTestBase |
16 | 17 |
17 import fake_repos | 18 import fake_repos |
18 import scm | 19 import scm |
19 import subprocess2 | 20 import subprocess2 |
20 | 21 |
21 | 22 |
22 class BaseTestCase(SuperMoxTestBase): | 23 class BaseTestCase(SuperMoxTestBase): |
23 # Like unittest's assertRaises, but checks for Gclient.Error. | 24 # Like unittest's assertRaises, but checks for Gclient.Error. |
24 def assertRaisesError(self, msg, fn, *args, **kwargs): | 25 def assertRaisesError(self, msg, fn, *args, **kwargs): |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 members = [ | 96 members = [ |
96 'AssertVersion', 'Capture', 'CaptureRevision', 'CaptureInfo', | 97 'AssertVersion', 'Capture', 'CaptureRevision', 'CaptureInfo', |
97 'CaptureStatus', 'current_version', 'DiffItem', 'GenerateDiff', | 98 'CaptureStatus', 'current_version', 'DiffItem', 'GenerateDiff', |
98 'GetCheckoutRoot', 'GetEmail', 'GetFileProperty', 'IsMoved', | 99 'GetCheckoutRoot', 'GetEmail', 'GetFileProperty', 'IsMoved', |
99 'IsMovedInfo', 'ReadSimpleAuth', 'Revert', 'RunAndGetFileList', | 100 'IsMovedInfo', 'ReadSimpleAuth', 'Revert', 'RunAndGetFileList', |
100 ] | 101 ] |
101 # If this test fails, you should add the relevant test. | 102 # If this test fails, you should add the relevant test. |
102 self.compareMembers(scm.SVN, members) | 103 self.compareMembers(scm.SVN, members) |
103 | 104 |
104 def testGetCheckoutRoot(self): | 105 def testGetCheckoutRoot(self): |
| 106 # pylint: disable=E1103 |
105 self.mox.StubOutWithMock(scm.SVN, 'CaptureInfo') | 107 self.mox.StubOutWithMock(scm.SVN, 'CaptureInfo') |
106 self.mox.StubOutWithMock(scm, 'GetCasedPath') | 108 self.mox.StubOutWithMock(scm, 'GetCasedPath') |
107 scm.os.path.abspath = lambda x: x | 109 scm.os.path.abspath = lambda x: x |
108 scm.GetCasedPath = lambda x: x | 110 scm.GetCasedPath = lambda x: x |
109 # pylint: disable=E1103 | |
110 scm.SVN.CaptureInfo(self.root_dir + '/foo/bar').AndReturn({ | 111 scm.SVN.CaptureInfo(self.root_dir + '/foo/bar').AndReturn({ |
111 'Repository Root': 'svn://svn.chromium.org/chrome', | 112 'Repository Root': 'svn://svn.chromium.org/chrome', |
112 'URL': 'svn://svn.chromium.org/chrome/trunk/src', | 113 'URL': 'svn://svn.chromium.org/chrome/trunk/src', |
113 }) | 114 }) |
114 scm.SVN.CaptureInfo(self.root_dir + '/foo').AndReturn({ | 115 scm.SVN.CaptureInfo(self.root_dir + '/foo').AndReturn({ |
115 'Repository Root': 'svn://svn.chromium.org/chrome', | 116 'Repository Root': 'svn://svn.chromium.org/chrome', |
116 'URL': 'svn://svn.chromium.org/chrome/trunk', | 117 'URL': 'svn://svn.chromium.org/chrome/trunk', |
117 }) | 118 }) |
118 scm.SVN.CaptureInfo(self.root_dir).AndReturn({ | 119 scm.SVN.CaptureInfo(self.root_dir).AndReturn({ |
119 'Repository Root': 'svn://svn.chromium.org/chrome', | 120 'Repository Root': 'svn://svn.chromium.org/chrome', |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 # Asserting the tree is not sufficient, svn status must come out clear too. | 337 # Asserting the tree is not sufficient, svn status must come out clear too. |
337 self.assertEquals('', self._capture(['status'])) | 338 self.assertEquals('', self._capture(['status'])) |
338 | 339 |
339 | 340 |
340 if __name__ == '__main__': | 341 if __name__ == '__main__': |
341 if '-v' in sys.argv: | 342 if '-v' in sys.argv: |
342 logging.basicConfig(level=logging.DEBUG) | 343 logging.basicConfig(level=logging.DEBUG) |
343 unittest.main() | 344 unittest.main() |
344 | 345 |
345 # vim: ts=2:sw=2:tw=80:et: | 346 # vim: ts=2:sw=2:tw=80:et: |
OLD | NEW |