本文整理汇总了Python中nailgun.client.put函数的典型用法代码示例。如果您正苦于以下问题:Python put函数的具体用法?Python put怎么用?Python put使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了put函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_update_auto_attach
def test_update_auto_attach(self):
"""@Test: Create an activation key, then update the auto_attach
field with the inverse boolean value.
@Feature: ActivationKey
@Assert:
1. The update succeeds with an HTTP 200 return code.
2. The value was changed.
"""
attrs = entities.ActivationKey().create_json()
activation_key = entities.ActivationKey(id=attrs['id'])
client.put(
activation_key.path(),
{'auto_attach': not attrs['auto_attach']},
auth=get_server_credentials(),
verify=False,
).raise_for_status()
# Status code is OK. Was `auto_attach` changed?
self.assertNotEqual(
activation_key.read_json()['auto_attach'],
attrs['auto_attach'],
)
示例2: test_update_docker_repo_url
def test_update_docker_repo_url(self, name):
"""@Test: Create a Docker-type repository and update its URL.
@Assert: A repository is created with a Docker image and that its
URL can be updated.
@Feature: Docker
"""
new_url = gen_url(scheme='https')
prod_id = entities.Product(
organization=self.org_id
).create_json()['id']
repo_id = _create_repository(prod_id, name)['id']
real_attrs = entities.Repository(id=repo_id).read_json()
self.assertEqual(real_attrs['url'], DOCKER_REGISTRY_HUB)
# Update the repository URL
real_attrs['url'] = new_url
client.put(
entities.Repository(id=repo_id).path(),
real_attrs,
auth=get_server_credentials(),
verify=False,
).raise_for_status()
new_attrs = entities.Repository(id=repo_id).read_json()
self.assertEqual(new_attrs['url'], new_url)
self.assertNotEqual(new_attrs['url'], DOCKER_REGISTRY_HUB)
示例3: test_update_docker_repo_upstream_name
def test_update_docker_repo_upstream_name(self, name):
"""@Test: Create a Docker-type repository and update its upstream name.
@Assert: A repository is created with a Docker image and that its
upstream name can be updated.
@Feature: Docker
@BZ: 1193669
"""
upstream_name = u'busybox'
new_upstream_name = u'fedora/ssh'
content_type = u'docker'
prod_id = entities.Product(
organization=self.org_id
).create_json()['id']
repo_id = _create_repository(prod_id, name, upstream_name)['id']
real_attrs = entities.Repository(id=repo_id).read_json()
self.assertEqual(real_attrs['name'], name)
self.assertEqual(real_attrs['docker_upstream_name'], upstream_name)
self.assertEqual(real_attrs['content_type'], content_type)
# Update the repository upstream name
real_attrs['docker_upstream_name'] = new_upstream_name
client.put(
entities.Repository(id=repo_id).path(),
real_attrs,
auth=get_server_credentials(),
verify=False,
).raise_for_status()
new_attrs = entities.Repository(id=repo_id).read_json()
self.assertEqual(new_attrs['docker_upstream_name'], new_upstream_name)
self.assertNotEqual(new_attrs['name'], upstream_name)
示例4: test_update
def test_update(self, entity_cls):
"""@Test: Check whether the "edit_*" role has an effect.
@Assert: A user cannot update an entity when missing the "edit_*" role,
and they can update an entity when given the "edit_*" role.
@Feature: Role
NOTE: This method will only work if ``entity`` has a name.
"""
entity_id = entity_cls().create_json()['id']
entity = entity_cls(self.server_config, id=entity_id)
with self.assertRaises(HTTPError):
client.put(
entity.path(),
{u'name': entity_cls.name.gen_value()},
auth=self.server_config.auth,
verify=self.server_config.verify,
).raise_for_status()
self.give_user_permission(_permission_name(entity_cls, 'update'))
client.put(
entity.path(),
{u'name': entity_cls.name.gen_value()},
auth=self.server_config.auth,
verify=self.server_config.verify,
).raise_for_status()
示例5: give_user_permission
def give_user_permission(self, perm_name):
"""Give ``self.user`` the ``perm_name`` permission.
This method creates a role and filter to accomplish the above goal.
When complete, the relevant relationhips look like this:
user → role ← filter → permission
:param str perm_name: The name of a permission. For example:
'create_architectures'.
:raises: ``AssertionError`` if more than one permission is found when
searching for the permission with name ``perm_name``.
:raises: ``requests.exceptions.HTTPError`` if an error occurs when
updating ``self.user``'s roles.
:returns: Nothing.
"""
role_id = entities.Role().create()['id']
permission_ids = [
permission['id']
for permission
in entities.Permission(name=perm_name).search()
]
self.assertEqual(len(permission_ids), 1)
entities.Filter(permission=permission_ids, role=role_id).create()
# NOTE: An extra hash is used due to an API bug.
client.put(
self.user.path(),
{u'user': {u'role_ids': [role_id]}},
auth=get_server_credentials(),
verify=False,
).raise_for_status()
示例6: test_update_gpgkey
def test_update_gpgkey(self):
"""@Test: Create a repository and update its GPGKey
@Assert: The updated repository points to a new GPG key.
@Feature: Repository
"""
# Create a repo and make it point to a GPG key.
key_1_id = entities.GPGKey(
content=read_data_file(VALID_GPG_KEY_FILE),
organization=self.org_id,
).create_json()['id']
repo_id = entities.Repository(
gpg_key=key_1_id,
product=self.prod_id,
).create_json()['id']
# Update the repo and make it point to a new GPG key.
key_2_id = entities.GPGKey(
content=read_data_file(VALID_GPG_KEY_BETA_FILE),
organization=self.org_id,
).create_json()['id']
client.put(
entities.Repository(id=repo_id).path(),
{u'gpg_key_id': key_2_id},
auth=get_server_credentials(),
verify=False,
).raise_for_status()
# Verify the repository's attributes.
attrs = entities.Repository(id=repo_id).read_json()
self.assertEqual(attrs['gpg_key_id'], key_2_id)
示例7: test_update
def test_update(self, attrs):
"""@Test: Create a repository and update its attributes.
@Assert: The repository's attributes are updated.
@Feature: Repository
"""
client.put(
self.repository.path(),
attrs,
auth=get_server_credentials(),
verify=False,
).raise_for_status()
real_attrs = self.repository.read_json()
for name, value in attrs.items():
self.assertIn(name, real_attrs.keys())
if name == 'content_type':
# Cannot update a repository's content type.
self.assertEqual(
entities.Repository.content_type.default,
real_attrs[name]
)
else:
self.assertEqual(value, real_attrs[name])
示例8: test_update_name
def test_update_name(self, content_type):
"""@Test: Update a repository's name.
@Assert: The repository's name is updated.
@Feature: Repository
The only data provided with the PUT request is a name. No other
information about the repository (such as its URL) is provided.
"""
if content_type == 'docker' and bz_bug_is_open(1194476):
self.skipTest(1194476)
repo_id = entities.Repository(
content_type=content_type
).create_json()['id']
name = entities.Repository.name.gen_value()
repository = entities.Repository(id=repo_id)
client.put(
repository.path(),
{'name': name},
auth=get_server_credentials(),
verify=False,
).raise_for_status()
self.assertEqual(name, repository.read_json()['name'])
示例9: test_add_normal_cv_to_composite
def test_add_normal_cv_to_composite(self):
"""@Test: Create normal content view, publish and
add it to a new composite content view
@Assert: Content view can be created and assigned to
composite one through content view versions
mechanism
@Feature: ContentView
"""
content_view = entities.ContentView(organization=self.org.id).create()
content_view.set_repository_ids([self.yum_repo.id])
content_view.publish()
cvv_id = content_view.read_json()['versions'][0]['id']
composite_cv = entities.ContentView(
composite=True,
organization=self.org.id,
).create()
client.put(
composite_cv.path(),
{'content_view': {'component_ids': [cvv_id]}},
auth=get_server_credentials(),
verify=False,
).raise_for_status()
cv_attrs = composite_cv.read_json()
self.assertEqual(cvv_id, cv_attrs['component_ids'][0])
self.assertEqual(
content_view.id,
cv_attrs['components'][0]['content_view_id'],
)
示例10: test_positive_update
def test_positive_update(self):
"""Create a repository and update its attributes.
@Assert: The repository's attributes are updated.
@Feature: Repository
"""
for attrs in _test_data():
with self.subTest(attrs):
client.put(
self.repository.path(),
attrs,
auth=settings.server.get_credentials(),
verify=False,
).raise_for_status()
real_attrs = self.repository.read_json()
for name, value in attrs.items():
self.assertIn(name, real_attrs.keys())
if name == 'content_type':
# Cannot update a repository's content type.
con_type = self.repository.get_fields()['content_type']
self.assertEqual(
con_type.default,
real_attrs[name]
)
else:
self.assertEqual(value, real_attrs[name])
示例11: test_delete_version_default
def test_delete_version_default(self):
"""@Test: Delete a content-view version associated to 'Library'
@Assert: Deletion fails
@Feature: ContentViewVersion
"""
key_content = read_data_file(ZOO_CUSTOM_GPG_KEY)
org = entities.Organization().create()
gpgkey_id = entities.GPGKey(
content=key_content,
organization=org.id
).create_json()['id']
# Creates new product without selecting GPGkey
product_id = entities.Product(
organization=org.id
).create_json()['id']
# Creates new repository with GPGKey
repo = entities.Repository(
url=FAKE_1_YUM_REPO,
product=product_id,
gpg_key=gpgkey_id,
).create()
# sync repository
repo.sync()
# Create content view
cv = entities.ContentView(
organization=org.id
).create()
# Associate repository to new content view
client.put(
cv.path(),
{u'repository_ids': [repo.id]},
auth=get_server_credentials(),
verify=False,
).raise_for_status()
# Publish content view
cv.publish()
# Get published content-view version info
cv_info = entities.ContentView(id=cv.id).read_json()
self.assertEqual(len(cv_info['versions']), 1)
# API returns version like '1.0'
version_num = cv_info['versions'][0]['version']
# WebUI displays version like 'Version 1.0'
version = 'Version {0}'.format(version_num)
with Session(self.browser) as session:
session.nav.go_to_select_org(org.name)
session.nav.go_to_content_views()
self.content_views.delete_version(cv.name, version)
self.content_views.check_progress_bar_status(version)
self.content_views.validate_version_deleted(cv.name, version)
示例12: _add_repo_to_content_view
def _add_repo_to_content_view(repo_id, cv_id):
"""Adds a repository to an existing content view.
:param int repo_id: The ID for an existing repository.
:param int cv_id: The ID for an existing content view.
"""
client.put(
entities.ContentView(id=cv_id).path(),
auth=get_server_credentials(),
verify=False,
data={u'repository_ids': [repo_id]}
).raise_for_status()
示例13: _add_content_view_to_composite_view
def _add_content_view_to_composite_view(cv_id, cv_version_id):
"""Adds a published content view to a composite content view.
:param int cv_id: The ID for an existing composite content view.
:param int cv_version_id: The ID for a published non-composite
content view.
"""
client.put(
entities.ContentView(id=cv_id).path(),
auth=get_server_credentials(),
verify=False,
data={u'component_ids': [cv_version_id]}
).raise_for_status()
示例14: test_positive_update_1
def test_positive_update_1(self, name_generator):
"""@Test: Update a role with and give a name of ``name_generator()``.
@Feature: Role
@Assert: The role is updated with the given name.
"""
if decorators.bz_bug_is_open(1112657) and (
name_generator is gen_cjk or
name_generator is gen_latin1 or
name_generator is gen_utf8):
self.skipTest('Bugzilla bug 1112657 is open.')
try:
role_id = entities.Role().create_json()['id']
except HTTPError as err:
self.fail(err) # fail instead of error
role = entities.Role(id=role_id)
name = name_generator()
response = client.put(
role.path(),
{u'name': name},
auth=get_server_credentials(),
verify=False,
)
response.raise_for_status()
self.assertEqual(role.read_json()['name'], name)
示例15: test_put_and_get
def test_put_and_get(self, entity_cls):
"""@Test: Update an entity, then read it back.
@Feature: Test multiple API paths
@Assert: The entity is updated with the given attributes.
"""
logger.debug('test_put_and_get arg: %s', entity_cls)
skip_if_sam(self, entity_cls)
if entity_cls in BZ_1154156_ENTITIES and bz_bug_is_open(1154156):
self.skipTest("Bugzilla bug 1154156 is open.")
# Create an entity.
entity_id = entity_cls().create_json()['id']
# Update that entity. FIXME: This whole procedure is a hack.
entity = entity_cls()
entity.create_missing() # Generate randomized instance attributes
response = client.put(
entity_cls(id=entity_id).path(),
entity.create_payload(),
auth=get_server_credentials(),
verify=False,
)
response.raise_for_status()
# Compare `payload` against entity information returned by the server.
payload = _get_readable_attributes(entity)
entity_attrs = entity_cls(id=entity_id).read_json()
for key, value in payload.items():
self.assertIn(key, entity_attrs.keys())
self.assertEqual(value, entity_attrs[key], key)