OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # Copyright (c) 2009 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 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 gcl.py.""" | 6 """Unit tests for gcl.py.""" |
7 | 7 |
8 import StringIO | 8 import StringIO |
9 import os | 9 import os |
10 import sys | 10 import sys |
(...skipping 30 matching lines...) Expand all Loading... |
41 | 41 |
42 class GclUnittest(GclTestsBase): | 42 class GclUnittest(GclTestsBase): |
43 """General gcl.py tests.""" | 43 """General gcl.py tests.""" |
44 def testMembersChanged(self): | 44 def testMembersChanged(self): |
45 members = [ | 45 members = [ |
46 'CODEREVIEW_SETTINGS', 'CODEREVIEW_SETTINGS_FILE', 'CPP_EXTENSIONS', | 46 'CODEREVIEW_SETTINGS', 'CODEREVIEW_SETTINGS_FILE', 'CPP_EXTENSIONS', |
47 'Change', 'ChangeInfo', 'Changes', 'Commit', 'DoPresubmitChecks', | 47 'Change', 'ChangeInfo', 'Changes', 'Commit', 'DoPresubmitChecks', |
48 'ErrorExit', 'GenerateChangeName', 'GenerateDiff', 'GetCLs', | 48 'ErrorExit', 'GenerateChangeName', 'GenerateDiff', 'GetCLs', |
49 'GetChangelistInfoFile', 'GetCodeReviewSetting', 'GetEditor', | 49 'GetChangelistInfoFile', 'GetCodeReviewSetting', 'GetEditor', |
50 'GetFilesNotInCL', 'GetInfoDir', 'GetIssueDescription', | 50 'GetFilesNotInCL', 'GetInfoDir', 'GetIssueDescription', |
51 'GetModifiedFiles', 'GetNamedNodeText', 'GetNodeNamedAttributeText', | 51 'GetModifiedFiles', 'GetRepositoryRoot', 'GetSVNStatus', |
52 'GetRepositoryRoot', 'GetSVNFileInfo', 'GetSVNStatus', | |
53 'GetSVNFileProperty', 'Help', 'IGNORE_PATHS', 'IsSVNMoved', 'IsTreeOpen', | 52 'GetSVNFileProperty', 'Help', 'IGNORE_PATHS', 'IsSVNMoved', 'IsTreeOpen', |
54 'Lint', 'LoadChangelistInfo', 'LoadChangelistInfoForMultiple', | 53 'Lint', 'LoadChangelistInfo', 'LoadChangelistInfoForMultiple', |
55 'MISSING_TEST_MSG', 'Opened', 'ParseXML', 'PresubmitCL', 'ReadFile', | 54 'MISSING_TEST_MSG', 'Opened', 'PresubmitCL', 'ReadFile', |
56 'RunShell', | 55 'RunShell', |
57 'RunShellWithReturnCode', 'SEPARATOR', 'SendToRietveld', 'TryChange', | 56 'RunShellWithReturnCode', 'SEPARATOR', 'SendToRietveld', 'TryChange', |
58 'UnknownFiles', 'UploadCL', 'Warn', 'WriteFile', 'gcl_info_dir', | 57 'UnknownFiles', 'UploadCL', 'Warn', 'WriteFile', 'gclient', |
59 'getpass', 'main', 'os', 'random', 're', 'read_gcl_info', | 58 'gcl_info_dir', 'getpass', 'main', 'os', 'random', 're', 'read_gcl_info', |
60 'repository_root', 'string', 'subprocess', 'sys', 'tempfile', 'upload', | 59 'repository_root', 'string', 'subprocess', 'sys', 'tempfile', 'upload', |
61 'urllib2', 'xml', | 60 'urllib2', 'xml', |
62 ] | 61 ] |
63 # If this test fails, you should add the relevant test. | 62 # If this test fails, you should add the relevant test. |
64 self.compareMembers(gcl, members) | 63 self.compareMembers(gcl, members) |
65 | 64 |
66 def testGetSVNFileInfo(self): | |
67 def RunShellMock(command): | |
68 return r"""<?xml version="1.0"?> | |
69 <info> | |
70 <entry kind="file" path="%s" revision="14628"> | |
71 <url>http://src.chromium.org/svn/trunk/src/chrome/app/d</url> | |
72 <repository><root>http://src.chromium.org/svn</root></repository> | |
73 <wc-info> | |
74 <schedule>add</schedule> | |
75 <depth>infinity</depth> | |
76 <copy-from-url>http://src.chromium.org/svn/trunk/src/chrome/app/DEPS</copy-from-
url> | |
77 <copy-from-rev>14628</copy-from-rev> | |
78 <checksum>369f59057ba0e6d9017e28f8bdfb1f43</checksum> | |
79 </wc-info> | |
80 </entry> | |
81 </info> | |
82 """ % command[3] | |
83 # GclTestsBase.tearDown will restore the original. | |
84 gcl.RunShell = RunShellMock | |
85 filename = os.path.join('app', 'd') | |
86 info = gcl.GetSVNFileInfo(filename) | |
87 expected = { | |
88 'URL': 'http://src.chromium.org/svn/trunk/src/chrome/app/d', | |
89 'Repository Root': 'http://src.chromium.org/svn', | |
90 'Schedule': 'add', | |
91 'Copied From URL': 'http://src.chromium.org/svn/trunk/src/chrome/app/DEPS'
, | |
92 'Copied From Rev': '14628', | |
93 'Path': filename, | |
94 'Node Kind': 'file', | |
95 } | |
96 self.assertEquals(sorted(info.items()), sorted(expected.items())) | |
97 | |
98 def testGetSVNStatus(self): | 65 def testGetSVNStatus(self): |
99 def RunShellMock(command): | 66 def RunShellMock(command): |
100 return r"""<?xml version="1.0"?> | 67 return r"""<?xml version="1.0"?> |
101 <status> | 68 <status> |
102 <target path="."> | 69 <target path="."> |
103 <entry path="unversionned_file.txt"> | 70 <entry path="unversionned_file.txt"> |
104 <wc-status props="none" item="unversioned"></wc-status> | 71 <wc-status props="none" item="unversioned"></wc-status> |
105 </entry> | 72 </entry> |
106 <entry path="build\internal\essential.vsprops"> | 73 <entry path="build\internal\essential.vsprops"> |
107 <wc-status props="normal" item="modified" revision="14628"> | 74 <wc-status props="normal" item="modified" revision="14628"> |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 self.assertEquals(o.name, 'name2') | 164 self.assertEquals(o.name, 'name2') |
198 self.assertEquals(o.issue, 'issue2') | 165 self.assertEquals(o.issue, 'issue2') |
199 self.assertEquals(o.description, 'description2') | 166 self.assertEquals(o.description, 'description2') |
200 self.assertEquals(o.files, files) | 167 self.assertEquals(o.files, files) |
201 self.assertEquals(o.patch, None) | 168 self.assertEquals(o.patch, None) |
202 self.assertEquals(o.FileList(), ['foo', 'bar']) | 169 self.assertEquals(o.FileList(), ['foo', 'bar']) |
203 | 170 |
204 | 171 |
205 if __name__ == '__main__': | 172 if __name__ == '__main__': |
206 unittest.main() | 173 unittest.main() |
OLD | NEW |