Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(104)

Side by Side Diff: tests/gclient_utils_test.py

Issue 9214004: Add UpgradeToHttps() to reliably and forcibly upgrade all urls to https (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Saner processing. Had to workaround urlparse default behavior Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tests/gcl_unittest.py ('k') | tests/git_cl_test.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 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
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', 'urlparse',
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):
49 class ProcessIdMock(object): 50 class ProcessIdMock(object):
50 def __init__(self, test_string): 51 def __init__(self, test_string):
51 self.stdout = StringIO.StringIO(test_string) 52 self.stdout = StringIO.StringIO(test_string)
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 ['foo/', 'https://foo/'],
182 ['ssh-svn://foo', 'ssh-svn://foo'],
183 ['ssh-svn://foo/bar/', 'ssh-svn://foo/bar/'],
184 ['codereview.chromium.org', 'https://chromiumcodereview.appspot.com'],
185 ['codereview.chromium.org/', 'https://chromiumcodereview.appspot.com/'],
186 ['http://foo:8080', 'http://foo:8080'],
187 ['http://foo:8080/bar', 'http://foo:8080/bar'],
188 ['foo:8080', 'http://foo:8080'],
189 ['foo:', 'https://foo:'],
190 ]
191 for content, expected in values:
192 self.assertEquals(
193 expected, gclient_utils.UpgradeToHttps(content))
194
174 def testParseCodereviewSettingsContent(self): 195 def testParseCodereviewSettingsContent(self):
175 expected = { 196 values = [
176 'Foo': 'bar:baz', 197 ['# bleh\n', {}],
177 'Second': 'value', 198 ['\t# foo : bar\n', {}],
178 } 199 ['Foo:bar', {'Foo': 'bar'}],
179 content = ( 200 ['Foo:bar:baz\n', {'Foo': 'bar:baz'}],
180 '# bleh\n' 201 [' Foo : bar ', {'Foo': 'bar'}],
181 '\t# foo : bar\n' 202 [' Foo : bar \n', {'Foo': 'bar'}],
182 'Foo:bar:baz\n' 203 ['a:b\n\rc:d\re:f', {'a': 'b', 'c': 'd', 'e': 'f'}],
183 ' Second : value \n\r' 204 ['an_url:http://value/', {'an_url': 'http://value/'}],
184 '#inconsistency' 205 [
185 ) 206 'CODE_REVIEW_SERVER : http://r/s',
186 self.assertEquals( 207 {'CODE_REVIEW_SERVER': 'https://r/s'}
187 expected, gclient_utils.ParseCodereviewSettingsContent(content)) 208 ],
209 ['VIEW_VC:http://r/s', {'VIEW_VC': 'https://r/s'}],
210 ]
211 for content, expected in values:
212 self.assertEquals(
213 expected, gclient_utils.ParseCodereviewSettingsContent(content))
188 214
189 215
190 if __name__ == '__main__': 216 if __name__ == '__main__':
191 import unittest 217 import unittest
192 unittest.main() 218 unittest.main()
193 219
194 # vim: ts=2:sw=2:tw=80:et: 220 # vim: ts=2:sw=2:tw=80:et:
OLDNEW
« no previous file with comments | « tests/gcl_unittest.py ('k') | tests/git_cl_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698