@tier1
def test_positive_update_name(self):
"""Create a Docker-type repository and update its name.
:id: 7967e6b5-c206-4ad0-bcf5-64a7ce85233b
:expectedresults: A repository is created with a Docker upstream
repository and that its name can be updated.
:CaseImportance: Critical
"""
repo = _create_repository(
entities.Product(organization=self.org).create())
# Update the repository name to random value
for new_name in valid_docker_repository_names():
with self.subTest(new_name):
repo.name = new_name
> repo = repo.update()
tests/foreman/api/test_docker.py:211:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.env/lib64/python3.7/site-packages/nailgun/entity_mixins.py:1058: in update
return self.read(attrs=self.update_json(fields))
.env/lib64/python3.7/site-packages/nailgun/entity_mixins.py:1034: in update_json
response = self.update_raw(fields)
.env/lib64/python3.7/site-packages/nailgun/entity_mixins.py:1016: in update_raw
self.update_payload(fields),
.env/lib64/python3.7/site-packages/nailgun/entity_mixins.py:1001: in update_payload
return _payload(self.get_fields(), values)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
fields = {'backend_identifier': <nailgun.entity_fields.StringField object at 0x7f9100e8bed0>, 'checksum_type': <nailgun.entity_...ringField object at 0x7f9100e35ad0>, 'content_counts': <nailgun.entity_fields.DictField object at 0x7f91006c4ad0>, ...}
values = {'backend_identifier': 'c0e005e0-9356-4470-8038-c9744e2a794f', 'checksum_type': None, 'container_repository_name': 'eb...e06', 'content_counts': {'ansible_collection': 0, 'deb': 0, 'docker_manifest': 0, 'docker_manifest_list': 0, ...}, ...}
def _payload(fields, values):
"""Implement the ``*_payload`` methods.
It's frequently useful to create a dict of values that can be encoded to
JSON and sent to the server. Unfortunately, there are mismatches between
the field names used by NailGun and the field names the server expects.
This method provides a default translation that works in many cases. For
example:
>>> from nailgun.entities import Product
>>> product = Product(name='foo', organization=1)
>>> set(product.get_fields())
{
'description',
'gpg_key',
'id',
'label',
'name',
'organization',
'sync_plan',
}
>>> set(product.get_values())
{'name', 'organization'}
>>> product.create_payload()
{'organization_id': 1, 'name': 'foo'}
:param fields: A value like what is returned by
:meth:`nailgun.entity_mixins.Entity.get_fields`.
:param values: A value like what is returned by
:meth:`nailgun.entity_mixins.Entity.get_values`.
:returns: A dict mapping field names to field values.
"""
for field_name, field in fields.items():
if field_name in values:
if isinstance(field, OneToOneField):
values[field_name + '_id'] = (
getattr(values.pop(field_name), 'id', None)
)
elif isinstance(field, OneToManyField):
values[field_name + '_ids'] = [
entity.id for entity in values.pop(field_name)
]
elif isinstance(field, ListField):
def parse(obj):
"""parse obj payload if it is an Entity"""
if isinstance(obj, Entity):
return _payload(obj.get_fields(), obj.get_values())
return obj
values[field_name] = [
> parse(obj) for obj in values[field_name]]
E TypeError: 'NoneType' object is not iterable
.env/lib64/python3.7/site-packages/nailgun/entity_mixins.py:208: TypeError
Tests cases :
tests/foreman/api/test_docker.py::DockerRepositoryTestCase::test_positive_update_url tests/foreman/api/test_docker.py::DockerRepositoryTestCase::test_positive_update_upstream_name tests/foreman/api/test_docker.py::DockerRepositoryTestCase::test_positive_update_name
i.e.