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 import os | 6 import os |
7 import StringIO | 7 import StringIO |
8 import sys | 8 import sys |
9 | 9 |
10 sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) | 10 sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) |
(...skipping 17 matching lines...) Expand all Loading... |
28 """General gclient_utils.py tests.""" | 28 """General gclient_utils.py tests.""" |
29 def testMembersChanged(self): | 29 def testMembersChanged(self): |
30 members = [ | 30 members = [ |
31 'Annotated', 'AutoFlush', 'CheckCallAndFilter', | 31 'Annotated', 'AutoFlush', 'CheckCallAndFilter', |
32 'CheckCallAndFilterAndHeader', 'Error', 'ExecutionQueue', 'FileRead', | 32 'CheckCallAndFilterAndHeader', 'Error', 'ExecutionQueue', 'FileRead', |
33 'FileWrite', 'FindFileUpwards', 'FindGclientRoot', | 33 'FileWrite', 'FindFileUpwards', 'FindGclientRoot', |
34 'GetGClientRootAndEntries', 'GetEditor', 'IsDateRevision', | 34 'GetGClientRootAndEntries', 'GetEditor', 'IsDateRevision', |
35 'MakeDateRevision', 'MakeFileAutoFlush', 'MakeFileAnnotated', | 35 'MakeDateRevision', 'MakeFileAutoFlush', 'MakeFileAnnotated', |
36 'PathDifference', 'ParseCodereviewSettingsContent', | 36 'PathDifference', 'ParseCodereviewSettingsContent', |
37 'PrintableObject', 'RemoveDirectory', 'RunEditor', | 37 'PrintableObject', 'RemoveDirectory', 'RunEditor', |
38 'SplitUrlRevision', 'SyntaxErrorToError', 'Wrapper', 'WorkItem', | 38 'SplitUrlRevision', 'SyntaxErrorToError', |
| 39 'UpgradeToHttps', 'Wrapper', 'WorkItem', |
39 'errno', 'lockedmethod', 'logging', 'os', 'Queue', 're', 'rmtree', | 40 'errno', 'lockedmethod', 'logging', 'os', 'Queue', 're', 'rmtree', |
40 'safe_makedirs', 'stat', 'subprocess2', 'sys', 'tempfile', 'threading', | 41 'safe_makedirs', 'stat', 'subprocess2', 'sys', 'tempfile', 'threading', |
41 'time', | 42 'time', |
42 ] | 43 ] |
43 # If this test fails, you should add the relevant test. | 44 # If this test fails, you should add the relevant test. |
44 self.compareMembers(gclient_utils, members) | 45 self.compareMembers(gclient_utils, members) |
45 | 46 |
46 | 47 |
47 | 48 |
48 class CheckCallAndFilterTestCase(GclientUtilBase): | 49 class CheckCallAndFilterTestCase(GclientUtilBase): |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 f3 = os.path.join(l3, 'f3') | 165 f3 = os.path.join(l3, 'f3') |
165 os.mkdir(l1) | 166 os.mkdir(l1) |
166 os.mkdir(l2) | 167 os.mkdir(l2) |
167 os.mkdir(l3) | 168 os.mkdir(l3) |
168 gclient_utils.FileWrite(f3, 'foo') | 169 gclient_utils.FileWrite(f3, 'foo') |
169 os.chmod(f3, 0) | 170 os.chmod(f3, 0) |
170 os.chmod(l3, 0) | 171 os.chmod(l3, 0) |
171 os.chmod(l2, 0) | 172 os.chmod(l2, 0) |
172 os.chmod(l1, 0) | 173 os.chmod(l1, 0) |
173 | 174 |
| 175 def testUpgradeToHttps(self): |
| 176 values = [ |
| 177 ['', ''], |
| 178 [None, None], |
| 179 ['foo', 'https://foo'], |
| 180 ['http://foo', 'https://foo'], |
| 181 ['ssh-svn://foo', 'ssh-svn://foo'], |
| 182 ] |
| 183 for content, expected in values: |
| 184 self.assertEquals( |
| 185 expected, gclient_utils.UpgradeToHttps(content)) |
| 186 |
174 def testParseCodereviewSettingsContent(self): | 187 def testParseCodereviewSettingsContent(self): |
175 expected = { | 188 values = [ |
176 'Foo': 'bar:baz', | 189 ['# bleh\n', {}], |
177 'Second': 'value', | 190 ['\t# foo : bar\n', {}], |
178 } | 191 ['Foo:bar', {'Foo': 'bar'}], |
179 content = ( | 192 ['Foo:bar:baz\n', {'Foo': 'bar:baz'}], |
180 '# bleh\n' | 193 [' Foo : bar ', {'Foo': 'bar'}], |
181 '\t# foo : bar\n' | 194 [' Foo : bar \n', {'Foo': 'bar'}], |
182 'Foo:bar:baz\n' | 195 ['a:b\n\rc:d\re:f', {'a': 'b', 'c': 'd', 'e': 'f'}], |
183 ' Second : value \n\r' | 196 ['an_url:http://value/', {'an_url': 'http://value/'}], |
184 '#inconsistency' | 197 [ |
185 ) | 198 'CODE_REVIEW_SERVER : http://r/s', |
186 self.assertEquals( | 199 {'CODE_REVIEW_SERVER': 'https://r/s'} |
187 expected, gclient_utils.ParseCodereviewSettingsContent(content)) | 200 ], |
| 201 ['VIEW_VC:http://r/s', {'VIEW_VC': 'https://r/s'}], |
| 202 ] |
| 203 for content, expected in values: |
| 204 self.assertEquals( |
| 205 expected, gclient_utils.ParseCodereviewSettingsContent(content)) |
188 | 206 |
189 | 207 |
190 if __name__ == '__main__': | 208 if __name__ == '__main__': |
191 import unittest | 209 import unittest |
192 unittest.main() | 210 unittest.main() |
193 | 211 |
194 # vim: ts=2:sw=2:tw=80:et: | 212 # vim: ts=2:sw=2:tw=80:et: |
OLD | NEW |