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 # pylint: disable=E1101,W0403 | 8 # pylint: disable=E1101,W0403 |
9 | 9 |
10 # Fixes include path. | 10 # Fixes include path. |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 'CaptureStatus', 'current_version', 'DiffItem', 'GenerateDiff', | 78 'CaptureStatus', 'current_version', 'DiffItem', 'GenerateDiff', |
79 'GetCheckoutRoot', 'GetEmail', 'GetFileProperty', 'IsMoved', | 79 'GetCheckoutRoot', 'GetEmail', 'GetFileProperty', 'IsMoved', |
80 'IsMovedInfo', 'ReadSimpleAuth', 'Revert', 'RunAndGetFileList', | 80 'IsMovedInfo', 'ReadSimpleAuth', 'Revert', 'RunAndGetFileList', |
81 ] | 81 ] |
82 # If this test fails, you should add the relevant test. | 82 # If this test fails, you should add the relevant test. |
83 self.compareMembers(scm.SVN, members) | 83 self.compareMembers(scm.SVN, members) |
84 | 84 |
85 def testGetCheckoutRoot(self): | 85 def testGetCheckoutRoot(self): |
86 self.mox.StubOutWithMock(scm.SVN, 'CaptureInfo') | 86 self.mox.StubOutWithMock(scm.SVN, 'CaptureInfo') |
87 self.mox.StubOutWithMock(scm, 'GetCasedPath') | 87 self.mox.StubOutWithMock(scm, 'GetCasedPath') |
88 scm.os.path.abspath(self.root_dir + 'x').AndReturn(self.root_dir) | 88 scm.os.path.abspath = lambda x: x |
89 scm.GetCasedPath(self.root_dir).AndReturn(self.root_dir) | 89 scm.GetCasedPath = lambda x: x |
90 result1 = { "Repository Root": "Some root" } | 90 scm.SVN.CaptureInfo(self.root_dir + '/foo/bar').AndReturn({ |
91 scm.SVN.CaptureInfo(self.root_dir).AndReturn(result1) | 91 'Repository Root': 'svn://svn.chromium.org/chrome', |
92 results2 = { "Repository Root": "A different root" } | 92 'URL': 'svn://svn.chromium.org/chrome/trunk/src', |
93 scm.SVN.CaptureInfo( | 93 }) |
94 scm.os.path.dirname(self.root_dir)).AndReturn(results2) | 94 scm.SVN.CaptureInfo(self.root_dir + '/foo').AndReturn({ |
| 95 'Repository Root': 'svn://svn.chromium.org/chrome', |
| 96 'URL': 'svn://svn.chromium.org/chrome/trunk', |
| 97 }) |
| 98 scm.SVN.CaptureInfo(self.root_dir).AndReturn({ |
| 99 'Repository Root': 'svn://svn.chromium.org/chrome', |
| 100 'URL': 'svn://svn.chromium.org/chrome/trunk/tools/commit-queue/workdir', |
| 101 }) |
95 self.mox.ReplayAll() | 102 self.mox.ReplayAll() |
96 self.assertEquals(scm.SVN.GetCheckoutRoot(self.root_dir + 'x'), | 103 self.assertEquals(scm.SVN.GetCheckoutRoot(self.root_dir + '/foo/bar'), |
97 self.root_dir) | 104 self.root_dir + '/foo') |
98 | 105 |
99 def testGetFileInfo(self): | 106 def testGetFileInfo(self): |
100 xml_text = r"""<?xml version="1.0"?> | 107 xml_text = r"""<?xml version="1.0"?> |
101 <info> | 108 <info> |
102 <entry kind="file" path="%s" revision="14628"> | 109 <entry kind="file" path="%s" revision="14628"> |
103 <url>http://src.chromium.org/svn/trunk/src/chrome/app/d</url> | 110 <url>http://src.chromium.org/svn/trunk/src/chrome/app/d</url> |
104 <repository><root>http://src.chromium.org/svn</root></repository> | 111 <repository><root>http://src.chromium.org/svn</root></repository> |
105 <wc-info> | 112 <wc-info> |
106 <schedule>add</schedule> | 113 <schedule>add</schedule> |
107 <depth>infinity</depth> | 114 <depth>infinity</depth> |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 self.mox.ReplayAll() | 238 self.mox.ReplayAll() |
232 info = scm.SVN.CaptureStatus(None) | 239 info = scm.SVN.CaptureStatus(None) |
233 self.assertEquals(info, []) | 240 self.assertEquals(info, []) |
234 | 241 |
235 | 242 |
236 if __name__ == '__main__': | 243 if __name__ == '__main__': |
237 import unittest | 244 import unittest |
238 unittest.main() | 245 unittest.main() |
239 | 246 |
240 # vim: ts=2:sw=2:tw=80:et: | 247 # vim: ts=2:sw=2:tw=80:et: |
OLD | NEW |