1
0
mirror of https://github.com/ansible/awx.git synced 2024-10-30 13:55:31 +03:00

finish editing the WFJT launch validate method

This commit is contained in:
AlanCoding 2016-10-19 10:11:04 -04:00
parent 9b7d046cec
commit 8ff671bfd6
3 changed files with 29 additions and 11 deletions

View File

@ -2609,19 +2609,20 @@ class JobLaunchSerializer(BaseSerializer):
class WorkflowJobLaunchSerializer(BaseSerializer):
can_start_without_user_input = serializers.BooleanField(read_only=True)
variables_needed_to_start = serializers.ReadOnlyField()
# can_start_without_user_input = serializers.BooleanField(read_only=True)
# variables_needed_to_start = serializers.ReadOnlyField()
survey_enabled = serializers.SerializerMethodField()
extra_vars = VerbatimField(required=False, write_only=True)
workflow_job_template_data = serializers.SerializerMethodField()
# workflow_job_template_data = serializers.SerializerMethodField()
# warnings =
class Meta:
model = WorkflowJobTemplate
fields = ('can_start_without_user_input',
fields = ('*',#'can_start_without_user_input',
'extra_vars',
'survey_enabled', 'variables_needed_to_start',
'workflow_job_template_data')
'survey_enabled')#, 'variables_needed_to_start',
# 'workflow_job_template_data')
def get_survey_enabled(self, obj):
if obj:

View File

@ -2786,12 +2786,13 @@ class WorkflowJobTemplateLabelList(JobTemplateLabelList):
new_in_310 = True
# TODO:
class WorkflowJobTemplateLaunch(GenericAPIView):
class WorkflowJobTemplateLaunch(RetrieveAPIView):
model = WorkflowJobTemplate
serializer_class = WorkflowJobLaunchSerializer
new_in_310 = True
is_job_start = True
always_allow_superuser = False
def update_raw_data(self, data):
obj = self.get_object()
@ -2802,7 +2803,7 @@ class WorkflowJobTemplateLaunch(GenericAPIView):
if extra_vars:
data['extra_vars'] = extra_vars
return data
# def get(self, request, *args, **kwargs):
# data = {}
# obj = self.get_object()

View File

@ -2,7 +2,11 @@ import pytest
import json
from awx.main.tasks import RunJob
from awx.main.models import Job
from awx.main.models import (
Job,
WorkflowJob,
WorkflowJobTemplate
)
@pytest.fixture
@ -65,3 +69,15 @@ def test_job_args_unredacted_passwords(job):
ev_index = args.index('-e') + 1
extra_vars = json.loads(args[ev_index])
assert extra_vars['secret_key'] == 'my_password'
class TestWorkflowSurveys:
def test_update_kwargs_survey_defaults(self, survey_spec_factory):
"Assure that the survey default over-rides a JT variable"
spec = survey_spec_factory('var1')
spec['spec'][0]['default'] = 3
wfjt = WorkflowJobTemplate(
name="test-wfjt",
survey_spec=spec,
extra_vars="var1: 5"
)
assert json.loads(wfjt._update_unified_job_kwargs()['extra_vars'])['var1'] == 3