Merge pull request #6572 from AlanCoding/approval_identifier

Allow setting identifier for approval nodes

Reviewed-by: Bianca Henderson <beeankha@gmail.com>
             https://github.com/beeankha
This commit is contained in:
softwarefactory-project-zuul[bot] 2020-04-06 13:39:39 +00:00 committed by GitHub
commit 9a91c0bfb2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 3 deletions

View File

@ -3611,9 +3611,11 @@ class LaunchConfigurationBaseSerializer(BaseSerializer):
elif self.instance:
ujt = self.instance.unified_job_template
if ujt is None:
if 'workflow_job_template' in attrs:
return {'workflow_job_template': attrs['workflow_job_template']}
return {}
ret = {}
for fd in ('workflow_job_template', 'identifier'):
if fd in attrs:
ret[fd] = attrs[fd]
return ret
# build additional field survey_passwords to track redacted variables
password_dict = {}

View File

@ -47,10 +47,35 @@ def test_create_workflow_job_template_node(run_module, admin_user, wfjt, job_tem
"changed": True
}
assert node.identifier == this_identifier
assert node.workflow_job_template_id == wfjt.id
assert node.unified_job_template_id == job_template.id
@pytest.mark.django_db
def test_create_workflow_job_template_node_no_template(run_module, admin_user, wfjt, job_template):
"""This is a part of the API contract for creating approval nodes
and at some point in the future, tha feature will be supported by the collection
"""
this_identifier = '42🐉'
result = run_module('tower_workflow_job_template_node', {
'identifier': this_identifier,
'workflow_job_template': wfjt.name,
'organization': wfjt.organization.name,
}, admin_user)
assert not result.get('failed', False), result.get('msg', result)
assert result.get('changed', False), result
node = WorkflowJobTemplateNode.objects.get(pk=result['id'])
# node = WorkflowJobTemplateNode.objects.first()
assert result['id'] == node.id
assert node.identifier == this_identifier
assert node.workflow_job_template_id == wfjt.id
assert node.unified_job_template_id is None
@pytest.mark.django_db
def test_make_use_of_prompts(run_module, admin_user, wfjt, job_template, machine_credential, vault_credential):
result = run_module('tower_workflow_job_template_node', {