本文整理汇总了Python中pulp_rpm.handler.repo_file.RepoFile.load方法的典型用法代码示例。如果您正苦于以下问题:Python RepoFile.load方法的具体用法?Python RepoFile.load怎么用?Python RepoFile.load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pulp_rpm.handler.repo_file.RepoFile
的用法示例。
在下文中一共展示了RepoFile.load方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_one_repo_save_and_load
# 需要导入模块: from pulp_rpm.handler.repo_file import RepoFile [as 别名]
# 或者: from pulp_rpm.handler.repo_file.RepoFile import load [as 别名]
def test_one_repo_save_and_load(self):
"""
Tests the normal flow of saving and loading, using only one repo to
minimize complications.
"""
# Setup
add_me = Repo('test-repo-1')
add_me['baseurl'] = 'http://localhost/repo'
add_me['enabled'] = 1
add_me['gpgkey'] = '/tmp/key'
add_me['sslverify'] = 0
add_me['gpgcheck'] = 0
add_me['sslcacert'] = '/tmp/sslcacert'
add_me['sslclientcert'] = '/tmp/clientcert'
repo_file = RepoFile(TEST_REPO_FILENAME)
# Test Save
repo_file.add_repo(add_me)
repo_file.save()
# Verify Save
self.assertTrue(os.path.exists(TEST_REPO_FILENAME))
# Test Load
loaded = RepoFile(TEST_REPO_FILENAME)
loaded.load()
# Verify Load
self.assertEqual(1, len(loaded.all_repos()))
found_repo = loaded.get_repo('test-repo-1')
self.assertTrue(found_repo is not None)
self.assertTrue(_repo_eq(add_me, found_repo))
示例2: test_multiple_repos
# 需要导入模块: from pulp_rpm.handler.repo_file import RepoFile [as 别名]
# 或者: from pulp_rpm.handler.repo_file.RepoFile import load [as 别名]
def test_multiple_repos(self):
"""
Tests saving and loading multiple repos.
"""
# Setup
repo1 = Repo('test-repo-1')
repo1['baseurl'] = 'http://localhost/repo1'
repo2 = Repo('test-repo-2')
repo2['baseurl'] = 'http://localhost/repo2'
repo_file = RepoFile(TEST_REPO_FILENAME)
# Test
repo_file.add_repo(repo1)
repo_file.add_repo(repo2)
repo_file.save()
# Verify
loaded = RepoFile(TEST_REPO_FILENAME)
loaded.load()
self.assertEqual(2, len(loaded.all_repos()))
found_repo1 = loaded.get_repo('test-repo-1')
self.assertTrue(found_repo1 is not None)
self.assertTrue(_repo_eq(repo1, found_repo1))
found_repo2 = loaded.get_repo('test-repo-2')
self.assertTrue(found_repo2 is not None)
self.assertTrue(_repo_eq(repo2, found_repo2))
示例3: test_bind_update_keys
# 需要导入模块: from pulp_rpm.handler.repo_file import RepoFile [as 别名]
# 或者: from pulp_rpm.handler.repo_file.RepoFile import load [as 别名]
def test_bind_update_keys(self):
"""
Tests changing the GPG keys on a previously bound repo.
"""
# Setup
keys = {'key1' : 'KEY1', 'key2' : 'KEY2'}
repolib.bind(TEST_REPO_FILENAME, TEST_MIRROR_LIST_FILENAME, TEST_KEYS_DIR, TEST_CERT_DIR, REPO_ID, REPO_NAME, ['http://pulp'], keys, None, None, ENABLED, LOCK)
# Test
new_keys = {'key1' : 'KEYX'}
repolib.bind(TEST_REPO_FILENAME, TEST_MIRROR_LIST_FILENAME, TEST_KEYS_DIR, TEST_CERT_DIR, REPO_ID, None, None, new_keys, None, None, ENABLED, LOCK)
# Verify
repo_file = RepoFile(TEST_REPO_FILENAME)
repo_file.load()
loaded = repo_file.get_repo(REPO_ID)
self.assertEqual(loaded['gpgcheck'], '1')
self.assertEqual(1, len(loaded['gpgkey'].split('\n')))
self.assertEqual(1, len(os.listdir(os.path.join(TEST_KEYS_DIR, REPO_ID))))
key_file = open(loaded['gpgkey'].split('\n')[0][5:], 'r')
contents = key_file.read()
key_file.close()
self.assertEqual(contents, 'KEYX')
示例4: test_bind_multiple_url
# 需要导入模块: from pulp_rpm.handler.repo_file import RepoFile [as 别名]
# 或者: from pulp_rpm.handler.repo_file.RepoFile import load [as 别名]
def test_bind_multiple_url(self):
"""
Tests that binding with a list of URLs will produce a mirror list and the
correct mirrorlist entry in the repo entry.
"""
# Test
url_list = ['http://pulpserver', 'http://otherserver']
repolib.bind(TEST_REPO_FILENAME, TEST_MIRROR_LIST_FILENAME, TEST_KEYS_DIR, TEST_CERT_DIR, REPO_ID, REPO_NAME, url_list, {}, None, None, ENABLED, LOCK)
# Verify
self.assertTrue(os.path.exists(TEST_REPO_FILENAME))
self.assertTrue(os.path.exists(TEST_MIRROR_LIST_FILENAME))
repo_file = RepoFile(TEST_REPO_FILENAME)
repo_file.load()
loaded = repo_file.get_repo(REPO_ID)
self.assertTrue('baseurl' not in loaded)
self.assertEqual(loaded['mirrorlist'], 'file:' + TEST_MIRROR_LIST_FILENAME)
mirror_list_file = MirrorListFile(TEST_MIRROR_LIST_FILENAME)
mirror_list_file.load()
self.assertEqual(mirror_list_file.entries[0], 'http://pulpserver')
self.assertEqual(mirror_list_file.entries[1], 'http://otherserver')
示例5: test_delete_repo
# 需要导入模块: from pulp_rpm.handler.repo_file import RepoFile [as 别名]
# 或者: from pulp_rpm.handler.repo_file.RepoFile import load [as 别名]
def test_delete_repo(self):
"""
Tests removing an existing repo is correctly saved and loaded
"""
# Setup
repo1 = Repo('test-repo-1')
repo2 = Repo('test-repo-2')
repo_file = RepoFile(TEST_REPO_FILENAME)
repo_file.add_repo(repo1)
repo_file.add_repo(repo2)
repo_file.save()
# Test
repo_file.remove_repo_by_name('test-repo-1')
repo_file.save()
# Verify
loaded = RepoFile(TEST_REPO_FILENAME)
loaded.load()
self.assertEqual(1, len(loaded.all_repos()))
self.assertTrue(loaded.get_repo('test-repo-1') is None)
self.assertTrue(loaded.get_repo('test-repo-2') is not None)
示例6: test_broken_load_allow_missing
# 需要导入模块: from pulp_rpm.handler.repo_file import RepoFile [as 别名]
# 或者: from pulp_rpm.handler.repo_file.RepoFile import load [as 别名]
def test_broken_load_allow_missing(self):
"""
Tests that an exception is raised when the file cannot be loaded because it is not
found.
"""
# Test
repo_file = RepoFile('/a/b/c/d')
repo_file.load(allow_missing=True)
示例7: test_no_repos_save_load
# 需要导入模块: from pulp_rpm.handler.repo_file import RepoFile [as 别名]
# 或者: from pulp_rpm.handler.repo_file.RepoFile import load [as 别名]
def test_no_repos_save_load(self):
"""
Tests that saving and loading a file with no repos is successful.
"""
# Test
repo_file = RepoFile(TEST_REPO_FILENAME)
repo_file.save()
# Verify
loaded = RepoFile(TEST_REPO_FILENAME)
loaded.load()
# Verify
self.assertEqual(0, len(loaded.all_repos()))
示例8: test_update_clientcert
# 需要导入模块: from pulp_rpm.handler.repo_file import RepoFile [as 别名]
# 或者: from pulp_rpm.handler.repo_file.RepoFile import load [as 别名]
def test_update_clientcert(self):
# setup
NEWCLIENTCRT = 'THE-NEW-CLIENT-CERT'
repolib.bind(
TEST_REPO_FILENAME,
TEST_MIRROR_LIST_FILENAME,
TEST_KEYS_DIR,
TEST_CERT_DIR,
REPO_ID,
REPO_NAME,
['http://pulp'],
[],
CACERT,
CLIENTCERT,
ENABLED,
LOCK)
repolib.bind(
TEST_REPO_FILENAME,
TEST_MIRROR_LIST_FILENAME,
TEST_KEYS_DIR,
TEST_CERT_DIR,
REPO_ID,
REPO_NAME,
['http://pulp'],
[],
CACERT,
NEWCLIENTCRT,
ENABLED,
LOCK)
repo_file = RepoFile(TEST_REPO_FILENAME)
repo_file.load()
loaded = repo_file.get_repo(REPO_ID)
# verify
certdir = os.path.join(TEST_CERT_DIR, REPO_ID)
self.assertTrue(len(os.listdir(certdir)), 2)
path = loaded['sslcacert']
f = open(path)
content = f.read()
f.close()
self.assertEqual(CACERT, content)
path = loaded['sslclientcert']
f = open(path)
content = f.read()
f.close()
self.assertEqual(NEWCLIENTCRT, content)
self.assertTrue(loaded['sslverify'], '1')
示例9: test_bind_host_urls_many_to_one
# 需要导入模块: from pulp_rpm.handler.repo_file import RepoFile [as 别名]
# 或者: from pulp_rpm.handler.repo_file.RepoFile import load [as 别名]
def test_bind_host_urls_many_to_one(self):
"""
Tests that changing from multiple URLs (mirrorlist usage) to a single URL
properly sets the repo metadata.
"""
# Setup
url_list = ['http://pulp1', 'http://pulp2']
repolib.bind(TEST_REPO_FILENAME, TEST_MIRROR_LIST_FILENAME, TEST_KEYS_DIR, TEST_CERT_DIR, REPO_ID, REPO_NAME, url_list, None, None, None, ENABLED, LOCK)
# Test
repolib.bind(TEST_REPO_FILENAME, TEST_MIRROR_LIST_FILENAME, TEST_KEYS_DIR, TEST_CERT_DIR, REPO_ID, REPO_NAME, ['http://pulpx'], None, None, None, ENABLED, LOCK)
# Verify
repo_file = RepoFile(TEST_REPO_FILENAME)
repo_file.load()
loaded = repo_file.get_repo(REPO_ID)
self.assertTrue('baseurl' in loaded)
self.assertTrue('mirrorlist' not in loaded)
示例10: test_bind_multiple_keys
# 需要导入模块: from pulp_rpm.handler.repo_file import RepoFile [as 别名]
# 或者: from pulp_rpm.handler.repo_file.RepoFile import load [as 别名]
def test_bind_multiple_keys(self):
"""
Tests that binding with multiple key URLs correctly stores the repo entry.
"""
# Test
url_list = ['http://pulpserver']
keys = {'key1' : 'KEY1', 'key2' : 'KEY2'}
repolib.bind(TEST_REPO_FILENAME, TEST_MIRROR_LIST_FILENAME, TEST_KEYS_DIR, TEST_CERT_DIR, REPO_ID, REPO_NAME, url_list, keys, None, None, ENABLED, LOCK)
# Verify
repo_file = RepoFile(TEST_REPO_FILENAME)
repo_file.load()
loaded = repo_file.get_repo(REPO_ID)
self.assertEqual(loaded['gpgcheck'], '1')
self.assertEqual(2, len(loaded['gpgkey'].split('\n')))
self.assertEqual(2, len(os.listdir(os.path.join(TEST_KEYS_DIR, REPO_ID))))
示例11: test_bind_single_url
# 需要导入模块: from pulp_rpm.handler.repo_file import RepoFile [as 别名]
# 或者: from pulp_rpm.handler.repo_file.RepoFile import load [as 别名]
def test_bind_single_url(self):
"""
Tests that binding with a single URL will produce a baseurl in the repo.
"""
# Test
url_list = ['http://pulpserver']
repolib.bind(TEST_REPO_FILENAME, TEST_MIRROR_LIST_FILENAME, TEST_KEYS_DIR, TEST_CERT_DIR, REPO_ID, REPO_NAME, url_list, {}, None, None, ENABLED, LOCK)
# Verify
self.assertTrue(os.path.exists(TEST_REPO_FILENAME))
self.assertTrue(not os.path.exists(TEST_MIRROR_LIST_FILENAME))
repo_file = RepoFile(TEST_REPO_FILENAME)
repo_file.load()
loaded = repo_file.get_repo(REPO_ID)
self.assertEqual(loaded['baseurl'], url_list[0])
self.assertTrue('mirrorlist' not in loaded)
示例12: test_bind_host_urls_one_to_many
# 需要导入模块: from pulp_rpm.handler.repo_file import RepoFile [as 别名]
# 或者: from pulp_rpm.handler.repo_file.RepoFile import load [as 别名]
def test_bind_host_urls_one_to_many(self):
"""
Tests that changing from a single URL to many properly updates the baseurl and
mirrorlist entries of the repo.
"""
# Setup
repolib.bind(TEST_REPO_FILENAME, TEST_MIRROR_LIST_FILENAME, TEST_KEYS_DIR, TEST_CERT_DIR, REPO_ID, REPO_NAME, ['https://pulpx'], None, None, None, ENABLED, LOCK)
# Test
url_list = ['http://pulp1', 'http://pulp2']
repolib.bind(TEST_REPO_FILENAME, TEST_MIRROR_LIST_FILENAME, TEST_KEYS_DIR, TEST_CERT_DIR, REPO_ID, REPO_NAME, url_list, None, None, None, ENABLED, LOCK)
# Verify
repo_file = RepoFile(TEST_REPO_FILENAME)
repo_file.load()
loaded = repo_file.get_repo(REPO_ID)
self.assertTrue('baseurl' not in loaded)
self.assertTrue('mirrorlist' in loaded)
示例13: test_unbind_repo_with_mirrorlist
# 需要导入模块: from pulp_rpm.handler.repo_file import RepoFile [as 别名]
# 或者: from pulp_rpm.handler.repo_file.RepoFile import load [as 别名]
def test_unbind_repo_with_mirrorlist(self):
"""
Tests that unbinding a repo that had a mirror list deletes the mirror list
file.
"""
# Setup
url_list = ['http://pulp1', 'http://pulp2', 'http://pulp3']
repolib.bind(TEST_REPO_FILENAME, TEST_MIRROR_LIST_FILENAME, TEST_KEYS_DIR, TEST_CERT_DIR, REPO_ID, REPO_NAME, url_list, {}, None, None, ENABLED, LOCK)
self.assertTrue(os.path.exists(TEST_MIRROR_LIST_FILENAME))
# Test
repolib.unbind(TEST_REPO_FILENAME, TEST_MIRROR_LIST_FILENAME, TEST_KEYS_DIR, TEST_CERT_DIR, REPO_ID, LOCK)
# Verify
repo_file = RepoFile(TEST_REPO_FILENAME)
repo_file.load()
self.assertEqual(0, len(repo_file.all_repos()))
self.assertTrue(not os.path.exists(TEST_MIRROR_LIST_FILENAME))
示例14: test_bind_update_remove_keys
# 需要导入模块: from pulp_rpm.handler.repo_file import RepoFile [as 别名]
# 或者: from pulp_rpm.handler.repo_file.RepoFile import load [as 别名]
def test_bind_update_remove_keys(self):
"""
Tests that updating a previously bound repo by removing its keys correctly
configures the repo and deletes the key files.
"""
# Setup
keys = {'key1' : 'KEY1', 'key2' : 'KEY2'}
repolib.bind(TEST_REPO_FILENAME, TEST_MIRROR_LIST_FILENAME, TEST_KEYS_DIR, TEST_CERT_DIR, REPO_ID, REPO_NAME, ['http://pulp'], keys, None, None, ENABLED, LOCK)
# Test
repolib.bind(TEST_REPO_FILENAME, TEST_MIRROR_LIST_FILENAME, TEST_KEYS_DIR, TEST_CERT_DIR, REPO_ID, None, None, {}, None, None, ENABLED, LOCK)
# Verify
repo_file = RepoFile(TEST_REPO_FILENAME)
repo_file.load()
loaded = repo_file.get_repo(REPO_ID)
self.assertEqual(loaded['gpgcheck'], '0')
self.assertEqual(loaded['gpgkey'], None)
self.assertTrue(not os.path.exists(os.path.join(TEST_KEYS_DIR, REPO_ID)))
示例15: test_mirrorlist_not_baseurl
# 需要导入模块: from pulp_rpm.handler.repo_file import RepoFile [as 别名]
# 或者: from pulp_rpm.handler.repo_file.RepoFile import load [as 别名]
def test_mirrorlist_not_baseurl(self):
"""
Tests that if a mirrorlist is specified, a baseurl entry isn't written to the
saved repo file.
"""
# Setup
repo = Repo('test-repo-1')
repo['mirrorlist'] = 'file://etc/pulp/mirrorlist'
repo_file = RepoFile(TEST_REPO_FILENAME)
repo_file.add_repo(repo)
repo_file.save()
# Test
loaded = RepoFile(TEST_REPO_FILENAME)
loaded.load()
loaded_repo = loaded.get_repo('test-repo-1')
self.assertEqual(loaded_repo['mirrorlist'], 'file://etc/pulp/mirrorlist')
self.assertTrue('baseurl' not in loaded_repo)