mirror of
https://github.com/ansible/awx.git
synced 2026-05-19 14:57:39 -02:30
fix the handling of wrong survey spec
This commit is contained in:
@@ -177,6 +177,38 @@ def test_job_template_with_survey_spec(run_module, admin_user, project, inventor
|
||||
assert ActivityStream.objects.count() == prior_ct
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_job_template_with_wrong_survey_spec(run_module, admin_user, project, inventory, survey_spec):
|
||||
result = run_module('tower_job_template', dict(
|
||||
name='foo',
|
||||
playbook='helloworld.yml',
|
||||
project=project.name,
|
||||
inventory=inventory.name,
|
||||
survey_spec=survey_spec,
|
||||
survey_enabled=True
|
||||
), admin_user)
|
||||
assert not result.get('failed', False), result.get('msg', result)
|
||||
assert result.get('changed', False), result
|
||||
jt = JobTemplate.objects.get(pk=result['id'])
|
||||
|
||||
assert jt.survey_spec == survey_spec
|
||||
|
||||
prior_ct = ActivityStream.objects.count()
|
||||
|
||||
del survey_spec['description']
|
||||
|
||||
result = run_module('tower_job_template', dict(
|
||||
name='foo',
|
||||
playbook='helloworld.yml',
|
||||
project=project.name,
|
||||
inventory=inventory.name,
|
||||
survey_spec=survey_spec,
|
||||
survey_enabled=True
|
||||
), admin_user)
|
||||
assert result.get('failed', True)
|
||||
assert result.get('msg') == "Failed to update survey: Field 'description' is missing from survey spec."
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_job_template_with_survey_encrypted_default(run_module, admin_user, project, inventory, silence_warning):
|
||||
spec = {
|
||||
|
||||
@@ -81,6 +81,34 @@ def test_survey_spec_only_changed(run_module, admin_user, organization, survey_s
|
||||
assert wfjt.survey_spec == survey_spec
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_survey_spec_only_changed(run_module, admin_user, organization, survey_spec):
|
||||
wfjt = WorkflowJobTemplate.objects.create(
|
||||
organization=organization, name='foo-workflow',
|
||||
survey_enabled=True, survey_spec=survey_spec
|
||||
)
|
||||
result = run_module('tower_workflow_job_template', {
|
||||
'name': 'foo-workflow',
|
||||
'organization': organization.name,
|
||||
'state': 'present'
|
||||
}, admin_user)
|
||||
assert not result.get('failed', False), result.get('msg', result)
|
||||
assert not result.get('changed', True), result
|
||||
wfjt.refresh_from_db()
|
||||
assert wfjt.survey_spec == survey_spec
|
||||
|
||||
del survey_spec['description']
|
||||
|
||||
result = run_module('tower_workflow_job_template', {
|
||||
'name': 'foo-workflow',
|
||||
'organization': organization.name,
|
||||
'survey_spec': survey_spec,
|
||||
'state': 'present'
|
||||
}, admin_user)
|
||||
assert result.get('failed', True)
|
||||
assert result.get('msg') == "Failed to update survey: Field 'description' is missing from survey spec."
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_associate_only_on_success(run_module, admin_user, organization, project):
|
||||
wfjt = WorkflowJobTemplate.objects.create(
|
||||
|
||||
Reference in New Issue
Block a user