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

Side by Side Diff: testing_support/gerrit_test_case.py

Issue 2075923003: Simplify octal constants in Python code (e.g. 0o0700 -> 0o700). (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Created 4 years, 6 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
« no previous file with comments | « no previous file | testing_support/git_test_utils.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 # Copyright (c) 2013 The Chromium OS Authors. All rights reserved. 1 # Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """Test framework for code that interacts with gerrit. 5 """Test framework for code that interacts with gerrit.
6 6
7 class GerritTestCase 7 class GerritTestCase
8 -------------------------------------------------------------------------------- 8 --------------------------------------------------------------------------------
9 This class initializes and runs an a gerrit instance on localhost. To use the 9 This class initializes and runs an a gerrit instance on localhost. To use the
10 framework, define a class that extends GerritTestCase, and then do standard 10 framework, define a class that extends GerritTestCase, and then do standard
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 http_port=http_port, 148 http_port=http_port,
149 netrc_file=os.path.join(gerrit_dir, 'tmp', '.netrc'), 149 netrc_file=os.path.join(gerrit_dir, 'tmp', '.netrc'),
150 ssh_ident=os.path.join(gerrit_dir, 'tmp', 'id_rsa'), 150 ssh_ident=os.path.join(gerrit_dir, 'tmp', 'id_rsa'),
151 ssh_port=ssh_port,) 151 ssh_port=ssh_port,)
152 152
153 @classmethod 153 @classmethod
154 def setUpClass(cls): 154 def setUpClass(cls):
155 """Sets up the gerrit instances in a class-specific temp dir.""" 155 """Sets up the gerrit instances in a class-specific temp dir."""
156 # Create gerrit instance. 156 # Create gerrit instance.
157 gerrit_dir = tempfile.mkdtemp() 157 gerrit_dir = tempfile.mkdtemp()
158 os.chmod(gerrit_dir, 0o0700) 158 os.chmod(gerrit_dir, 0o700)
159 gi = cls.gerrit_instance = cls._create_gerrit_instance(gerrit_dir) 159 gi = cls.gerrit_instance = cls._create_gerrit_instance(gerrit_dir)
160 160
161 # Set netrc file for http authentication. 161 # Set netrc file for http authentication.
162 cls.gerrit_util_netrc_orig = gerrit_util.NETRC 162 cls.gerrit_util_netrc_orig = gerrit_util.NETRC
163 gerrit_util.NETRC = netrc.netrc(gi.netrc_file) 163 gerrit_util.NETRC = netrc.netrc(gi.netrc_file)
164 164
165 # gerrit_util.py defaults to using https, but for testing, it's much 165 # gerrit_util.py defaults to using https, but for testing, it's much
166 # simpler to use http connections. 166 # simpler to use http connections.
167 cls.gerrit_util_protocol_orig = gerrit_util.GERRIT_PROTOCOL 167 cls.gerrit_util_protocol_orig = gerrit_util.GERRIT_PROTOCOL
168 gerrit_util.GERRIT_PROTOCOL = 'http' 168 gerrit_util.GERRIT_PROTOCOL = 'http'
(...skipping 12 matching lines...) Expand all
181 'access.refs/meta/config.read', 'group Anonymous Users']) 181 'access.refs/meta/config.read', 'group Anonymous Users'])
182 cls.check_call(['git', 'add', project_config], cwd=clone_path) 182 cls.check_call(['git', 'add', project_config], cwd=clone_path)
183 cls.check_call( 183 cls.check_call(
184 ['git', 'commit', '-m', 'Anonyous read for refs/meta/config'], 184 ['git', 'commit', '-m', 'Anonyous read for refs/meta/config'],
185 cwd=clone_path) 185 cwd=clone_path)
186 cls.check_call(['git', 'push', 'origin', 'HEAD:refs/meta/config'], 186 cls.check_call(['git', 'push', 'origin', 'HEAD:refs/meta/config'],
187 cwd=clone_path) 187 cwd=clone_path)
188 188
189 def setUp(self): 189 def setUp(self):
190 self.tempdir = tempfile.mkdtemp() 190 self.tempdir = tempfile.mkdtemp()
191 os.chmod(self.tempdir, 0o0700) 191 os.chmod(self.tempdir, 0o700)
192 192
193 def tearDown(self): 193 def tearDown(self):
194 if TEARDOWN: 194 if TEARDOWN:
195 shutil.rmtree(self.tempdir) 195 shutil.rmtree(self.tempdir)
196 196
197 @classmethod 197 @classmethod
198 def createProject(cls, name, description='Test project', owners=None, 198 def createProject(cls, name, description='Test project', owners=None,
199 submit_type='CHERRY_PICK'): 199 submit_type='CHERRY_PICK'):
200 """Create a project on the test gerrit server.""" 200 """Create a project on the test gerrit server."""
201 if owners is None: 201 if owners is None:
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 ['git', 'config', 'remote.%s.review' % remote], 469 ['git', 'config', 'remote.%s.review' % remote],
470 cwd=clone_path).strip() 470 cwd=clone_path).strip()
471 assert(review_host) 471 assert(review_host)
472 projectname = self.check_output( 472 projectname = self.check_output(
473 ['git', 'config', 'remote.%s.projectname' % remote], 473 ['git', 'config', 'remote.%s.projectname' % remote],
474 cwd=clone_path).strip() 474 cwd=clone_path).strip()
475 assert(projectname) 475 assert(projectname)
476 GerritTestCase._UploadChange( 476 GerritTestCase._UploadChange(
477 clone_path, branch=branch, remote='%s://%s/%s' % ( 477 clone_path, branch=branch, remote='%s://%s/%s' % (
478 gerrit_util.GERRIT_PROTOCOL, review_host, projectname)) 478 gerrit_util.GERRIT_PROTOCOL, review_host, projectname))
OLDNEW
« no previous file with comments | « no previous file | testing_support/git_test_utils.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698