本文整理汇总了Python中pysflib.sfgerrit.GerritUtils类的典型用法代码示例。如果您正苦于以下问题:Python GerritUtils类的具体用法?Python GerritUtils怎么用?Python GerritUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了GerritUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _prepare_review_submit_testing
def _prepare_review_submit_testing(self, project_options=None):
if project_options is None:
u2mail = config.USERS[config.USER_2]['email']
project_options = {'core-group': u2mail}
pname = 'p_%s' % create_random_str()
self.create_project(pname, project_options)
un = config.ADMIN_USER
gu = GerritUtils(
config.GATEWAY_URL,
auth_cookie=config.USERS[un]['auth_cookie'])
k_index = gu.add_pubkey(config.USERS[un]["pubkey"])
self.assertTrue(gu.project_exists(pname))
priv_key_path = set_private_key(config.USERS[un]["privkey"])
gitu = GerritGitUtils(un,
priv_key_path,
config.USERS[un]['email'])
url = "ssh://%[email protected]%s:29418/%s" % (un, config.GATEWAY_HOST,
pname)
clone_dir = gitu.clone(url, pname)
self.dirs_to_delete.append(os.path.dirname(clone_dir))
gitu.add_commit_and_publish(clone_dir, "master", "Test commit")
change_ids = gu.get_my_changes_for_project(pname)
self.assertEqual(len(change_ids), 1)
change_id = change_ids[0]
return change_id, gu, k_index
示例2: setUp
def setUp(self):
self.msu = ManageSfUtils(config.GATEWAY_URL)
self.un = config.ADMIN_USER
self.gu = GerritUtils(
config.GATEWAY_URL,
auth_cookie=config.USERS[self.un]['auth_cookie'])
self.gu2 = GerritUtils(
config.GATEWAY_URL,
auth_cookie=config.USERS[config.USER_2]['auth_cookie'])
self.k_idx = self.gu2.add_pubkey(config.USERS[config.USER_2]["pubkey"])
priv_key_path = set_private_key(config.USERS[self.un]["privkey"])
self.gitu_admin = GerritGitUtils(self.un,
priv_key_path,
config.USERS[self.un]['email'])
# Configuration to access mirror repo present in mysql
self.msql_repo_path = "ssh://%[email protected]%s/%s" \
% (config.GERRIT_USER, config.GATEWAY_HOST,
'home/gerrit/site_path/git/')
# prepare environment for git clone on mirror repo
self.mt = Tool()
self.mt_tempdir = tempfile.mkdtemp()
priv_key = file(config.GERRIT_SERVICE_PRIV_KEY_PATH, 'r').read()
priv_key_path = os.path.join(self.mt_tempdir, 'user.priv')
file(priv_key_path, 'w').write(priv_key)
os.chmod(priv_key_path, stat.S_IREAD | stat.S_IWRITE)
ssh_wrapper = "ssh -o StrictHostKeyChecking=no -i " \
"%s \"[email protected]\"" % priv_key_path
wrapper_path = os.path.join(self.mt_tempdir, 'ssh_wrapper.sh')
file(wrapper_path, 'w').write(ssh_wrapper)
os.chmod(wrapper_path, stat.S_IRWXU)
self.mt.env['GIT_SSH'] = wrapper_path
self.pname = 'test-replication'
示例3: test_create_public_project_as_user_clone_as_user
def test_create_public_project_as_user_clone_as_user(self):
""" Create public project as user then clone as user
"""
pname = 'p_%s' % create_random_str()
# create the project as admin
self.create_project(pname, config.USER_2)
# add user2 ssh pubkey to user2
gu = GerritUtils(
'https://%s/' % config.GATEWAY_HOST,
auth_cookie=config.USERS[config.USER_2]['auth_cookie'])
gu.add_pubkey(config.USER_2_PUB_KEY)
# prepare to clone
priv_key_path = set_private_key(config.USER_2_PRIV_KEY)
self.dirs_to_delete.append(os.path.dirname(priv_key_path))
ggu = GerritGitUtils(config.USER_2,
priv_key_path,
config.USERS[config.USER_2]['email'])
url = "ssh://%[email protected]%s:29418/%s" % (config.USER_2,
config.GATEWAY_HOST, pname)
# clone
clone_dir = ggu.clone(url, pname)
self.dirs_to_delete.append(os.path.dirname(clone_dir))
# Test that the clone is a success
self.assertTrue(os.path.isdir(clone_dir))
# Verify master own the .gitreview file
self.assertTrue(os.path.isfile(os.path.join(clone_dir,
'.gitreview')))
示例4: setUp
def setUp(self):
self.projects = []
self.dirs_to_delete = []
self.un = config.ADMIN_USER
self.gu = GerritUtils(
config.GATEWAY_URL,
auth_cookie=config.USERS[self.un]['auth_cookie'])
self.gu2 = GerritUtils(
config.GATEWAY_URL,
auth_cookie=config.USERS[config.USER_2]['auth_cookie'])
self.ju = JenkinsUtils()
self.gu.add_pubkey(config.USERS[self.un]["pubkey"])
priv_key_path = set_private_key(config.USERS[self.un]["privkey"])
self.gitu_admin = GerritGitUtils(self.un,
priv_key_path,
config.USERS[self.un]['email'])
# Clone the config repo and make change to it
# in order to test the new sample_project
self.config_clone_dir = self.clone_as_admin("config")
self.original_layout = file(os.path.join(
self.config_clone_dir, "zuul/layout.yaml")).read()
self.original_zuul_projects = file(os.path.join(
self.config_clone_dir, "zuul/projects.yaml")).read()
self.original_project = file(os.path.join(
self.config_clone_dir, "jobs/projects.yaml")).read()
# Put USER_2 as core for config project
self.gu.add_group_member(config.USER_2, "config-core")
示例5: test_plugins_installed
def test_plugins_installed(self):
""" Test if plugins are present
"""
gu = GerritUtils(
config.GATEWAY_URL,
auth_cookie=config.USERS[config.ADMIN_USER]['auth_cookie'])
plugins = gu.list_plugins()
self.assertIn('download-commands', plugins)
self.assertIn('avatars-gravatar', plugins)
self.assertIn('reviewers-by-blame', plugins)
示例6: test_plugins_installed
def test_plugins_installed(self):
""" Test if plugins are present
"""
gu = GerritUtils(
'https://%s/' % config.GATEWAY_HOST,
auth_cookie=config.USERS[config.ADMIN_USER]['auth_cookie'])
plugins = gu.list_plugins()
self.assertIn('download-commands', plugins)
self.assertIn('gravatar-avatar-provider', plugins)
self.assertIn('reviewers-by-blame', plugins)
示例7: test_check_config_repo_exists
def test_check_config_repo_exists(self):
""" Validate config repo has been bootstraped
"""
pname = "config"
gu = GerritUtils(config.GATEWAY_URL, auth_cookie=config.USERS[config.ADMIN_USER]["auth_cookie"])
self.assertTrue(gu.project_exists(pname))
ggu = GerritGitUtils(config.ADMIN_USER, config.ADMIN_PRIV_KEY_PATH, config.USERS[config.ADMIN_USER]["email"])
url = "ssh://%[email protected]%s:29418/%s" % (config.ADMIN_USER, config.GATEWAY_HOST, pname)
clone_dir = ggu.clone(url, pname)
# Test that the clone is a success
self.assertTrue(os.path.isdir(clone_dir))
# Check if the clone dir has projects file
self.assertTrue(os.path.isfile(os.path.join(clone_dir, "jobs/projects.yaml")))
示例8: setUp
def setUp(self):
self.projects = []
self.rm = get_issue_tracker_utils(
auth_cookie=config.USERS[config.ADMIN_USER]['auth_cookie'])
self.gu = GerritUtils(
config.GATEWAY_URL,
auth_cookie=config.USERS[config.ADMIN_USER]['auth_cookie'])
示例9: setUp
def setUp(self):
self.projects = []
self.dirs_to_delete = []
self.rm = RedmineUtils(
config.GATEWAY_URL + "/redmine/", auth_cookie=config.USERS[config.ADMIN_USER]["auth_cookie"]
)
self.gu = GerritUtils(config.GATEWAY_URL, auth_cookie=config.USERS[config.ADMIN_USER]["auth_cookie"])
示例10: setUp
def setUp(self):
self.projects = []
self.rm = RedmineUtils(
config.REDMINE_URL,
auth_cookie=config.USERS[config.ADMIN_USER]['auth_cookie'])
self.gu = GerritUtils(
'https://%s/' % config.GATEWAY_HOST,
auth_cookie=config.USERS[config.ADMIN_USER]['auth_cookie'])
示例11: test_review_labels
def test_review_labels(self):
""" Test if list of review labels are as expected
"""
pname = 'p_%s' % create_random_str()
self.create_project(pname)
un = config.ADMIN_USER
gu = GerritUtils(
config.GATEWAY_URL,
auth_cookie=config.USERS[un]['auth_cookie'])
k_index = gu.add_pubkey(config.USERS[un]["pubkey"])
self.assertTrue(gu.project_exists(pname))
priv_key_path = set_private_key(config.USERS[un]["privkey"])
gitu = GerritGitUtils(un,
priv_key_path,
config.USERS[un]['email'])
url = "ssh://%[email protected]%s:29418/%s" % (un, config.GATEWAY_HOST,
pname)
clone_dir = gitu.clone(url, pname)
self.dirs_to_delete.append(os.path.dirname(clone_dir))
gitu.add_commit_and_publish(clone_dir, "master", "Test commit")
change_ids = gu.get_my_changes_for_project(pname)
self.assertEqual(len(change_ids), 1)
change_id = change_ids[0]
labels = gu.get_labels_list_for_change(change_id)
self.assertIn('Workflow', labels)
self.assertIn('Code-Review', labels)
self.assertIn('Verified', labels)
self.assertEqual(len(labels.keys()), 3)
gu.del_pubkey(k_index)
示例12: test_check_config_repo_exists
def test_check_config_repo_exists(self):
pname = 'config'
gu = GerritUtils(
'https://%s/' % config.GATEWAY_HOST,
auth_cookie=config.USERS[config.ADMIN_USER]['auth_cookie'])
self.assertTrue(gu.project_exists(pname))
ggu = GerritGitUtils(config.ADMIN_USER,
config.ADMIN_PRIV_KEY_PATH,
config.USERS[config.ADMIN_USER]['email'])
url = "ssh://%[email protected]%s:29418/%s" % (config.ADMIN_USER,
config.GATEWAY_HOST, pname)
clone_dir = ggu.clone(url, pname)
# Test that the clone is a success
self.assertTrue(os.path.isdir(clone_dir))
# Check if the clone dir has projects file
self.assertTrue(os.path.isfile(os.path.join(clone_dir,
"jobs/projects.yaml")))
示例13: setUp
def setUp(self):
self.projects = []
self.dirs_to_delete = []
self.issues = []
self.u = config.ADMIN_USER
self.u2 = config.USER_2
self.rm = get_issue_tracker_utils(
auth_cookie=config.USERS[config.ADMIN_USER]['auth_cookie'])
self.gu = GerritUtils(
config.GATEWAY_URL,
auth_cookie=config.USERS[self.u]['auth_cookie'])
self.gu2 = GerritUtils(
config.GATEWAY_URL,
auth_cookie=config.USERS[self.u2]['auth_cookie'])
self.gu.add_pubkey(config.USERS[self.u]["pubkey"])
priv_key_path = set_private_key(config.USERS[self.u]["privkey"])
self.gitu = GerritGitUtils(self.u,
priv_key_path,
config.USERS[self.u]['email'])
示例14: setUp
def setUp(self):
self.projects = []
self.dirs_to_delete = []
self.issues = []
self.u = config.ADMIN_USER
self.u2 = config.USER_2
self.rm = RedmineUtils(
config.REDMINE_URL,
auth_cookie=config.USERS[config.ADMIN_USER]['auth_cookie'])
self.gu = GerritUtils(
'https://%s/' % config.GATEWAY_HOST,
auth_cookie=config.USERS[self.u]['auth_cookie'])
self.gu2 = GerritUtils(
'https://%s/' % config.GATEWAY_HOST,
auth_cookie=config.USERS[self.u2]['auth_cookie'])
self.gu.add_pubkey(config.USERS[self.u]["pubkey"])
priv_key_path = set_private_key(config.USERS[self.u]["privkey"])
self.gitu = GerritGitUtils(self.u,
priv_key_path,
config.USERS[self.u]['email'])
示例15: test_gerrit_api_accessible
def test_gerrit_api_accessible(self):
""" Test if Gerrit API is accessible on gateway hosts
"""
m = ManageSfUtils(config.GATEWAY_URL)
url = config.GATEWAY_URL + "/api/"
a = GerritUtils(url)
a.g.url = "%s/" % a.g.url.rstrip('a/')
self.assertRaises(HTTPError, a.get_account, config.USER_1)
api_passwd = m.create_gerrit_api_password(config.USER_1)
auth = HTTPBasicAuth(config.USER_1, api_passwd)
a = GerritUtils(url, auth=auth)
self.assertTrue(a.get_account(config.USER_1))
m.delete_gerrit_api_password(config.USER_1)
a = GerritUtils(url, auth=auth)
self.assertRaises(HTTPError, a.get_account, config.USER_1)
a = GerritUtils(url)
a.g.url = "%s/" % a.g.url.rstrip('a/')
self.assertRaises(HTTPError, a.get_account, 'john')