WIP Inclusion of the EE option in the payloads within the Organization and Projects. (#9145)

* add ee option on factories for organizations

* add new lines

* remove inventory from the options

* remove line

* remove line from projects

* fix the tuple

* fix lint problems
This commit is contained in:
Yago Marques 2021-01-26 16:57:01 -03:00 committed by Shane McDonald
parent fd0c4ec869
commit 8ab7745e3a
2 changed files with 21 additions and 1 deletions

View File

@ -39,10 +39,20 @@ class Organization(HasCreate, HasInstanceGroups, HasNotifications, base.Base):
"disassociate": True,
})
def payload(self, **kwargs):
payload = PseudoNamespace(name=kwargs.get('name') or 'Organization - {}'.format(random_title()),
description=kwargs.get('description') or random_title(10))
for fk_field in ('default_environment',):
rel_obj = kwargs.get(fk_field)
if rel_obj is None:
continue
elif isinstance(rel_obj, int):
payload.update(**{fk_field: int(rel_obj)})
elif hasattr(rel_obj, 'id'):
payload.update(**{fk_field: rel_obj.id})
else:
raise AttributeError(f'Related field {fk_field} must be either integer of pkid or object')
return payload
def create_payload(self, name='', description='', **kwargs):

View File

@ -43,6 +43,16 @@ class Project(HasCopy, HasCreate, HasNotifications, UnifiedJobTemplate):
'allow_override')
update_payload(payload, fields, kwargs)
for fk_field in ('execution_environment', 'default_environment'):
rel_obj = kwargs.get(fk_field)
if rel_obj is None:
continue
elif isinstance(rel_obj, int):
payload.update(**{fk_field: int(rel_obj)})
elif hasattr(rel_obj, 'id'):
payload.update(**{fk_field: rel_obj.id})
else:
raise AttributeError(f'Related field {fk_field} must be either integer of pkid or object')
return payload
def create_payload(