mirror of
https://github.com/ansible/awx.git
synced 2026-03-15 16:07:30 -02:30
Reenable test for key=value extra vars, remove some unused imports.
This commit is contained in:
@@ -14,9 +14,6 @@ import uuid
|
|||||||
import copy
|
import copy
|
||||||
import random
|
import random
|
||||||
|
|
||||||
# PyYAML
|
|
||||||
import yaml
|
|
||||||
|
|
||||||
# Django
|
# Django
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.db import models, connection
|
from django.db import models, connection
|
||||||
|
|||||||
@@ -12,9 +12,6 @@ import re
|
|||||||
import shlex
|
import shlex
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
# PyYAML
|
|
||||||
import yaml
|
|
||||||
|
|
||||||
# Django
|
# Django
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.db import models
|
from django.db import models
|
||||||
@@ -456,18 +453,7 @@ class Job(UnifiedJob, JobOptions):
|
|||||||
extra_vars = json.loads(extra_data)
|
extra_vars = json.loads(extra_data)
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
logger.warn("Exception deserializing extra vars: " + str(e))
|
logger.warn("Exception deserializing extra vars: " + str(e))
|
||||||
if self.extra_vars is None or self.extra_vars == "":
|
evars = self.extra_vars_dict
|
||||||
evars = {}
|
|
||||||
elif type(self.extra_vars) == dict:
|
|
||||||
evars = self.extra_vars
|
|
||||||
else:
|
|
||||||
try:
|
|
||||||
evars = json.loads(self.extra_vars)
|
|
||||||
except ValueError:
|
|
||||||
try:
|
|
||||||
evars = yaml.safe_load(self.extra_vars)
|
|
||||||
except yaml.YAMLError:
|
|
||||||
evars = {}
|
|
||||||
evars.update(extra_vars)
|
evars.update(extra_vars)
|
||||||
self.update_fields(extra_vars=json.dumps(evars))
|
self.update_fields(extra_vars=json.dumps(evars))
|
||||||
|
|
||||||
|
|||||||
@@ -13,9 +13,6 @@ import shlex
|
|||||||
import urlparse
|
import urlparse
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
# PyYAML
|
|
||||||
import yaml
|
|
||||||
|
|
||||||
# Django
|
# Django
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.db import models
|
from django.db import models
|
||||||
|
|||||||
@@ -11,9 +11,6 @@ import os
|
|||||||
import os.path
|
import os.path
|
||||||
from StringIO import StringIO
|
from StringIO import StringIO
|
||||||
|
|
||||||
# PyYAML
|
|
||||||
import yaml
|
|
||||||
|
|
||||||
# Django
|
# Django
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.db import models
|
from django.db import models
|
||||||
|
|||||||
@@ -887,14 +887,14 @@ class RunJobTest(BaseCeleryTest):
|
|||||||
self.assertTrue('"--forks=3"' in job.job_args)
|
self.assertTrue('"--forks=3"' in job.job_args)
|
||||||
self.assertTrue('"-vv"' in job.job_args)
|
self.assertTrue('"-vv"' in job.job_args)
|
||||||
self.assertTrue('"-e"' in job.job_args)
|
self.assertTrue('"-e"' in job.job_args)
|
||||||
# Test with extra_vars as key=value (old format).
|
# Test with extra_vars as key=value (old format, still supported by
|
||||||
# TODO: Do we still support this?
|
# -e option to ansible-playbook).
|
||||||
# job_template2 = self.create_test_job_template(extra_vars='foo=1')
|
job_template2 = self.create_test_job_template(extra_vars='foo=1')
|
||||||
# job2 = self.create_test_job(job_template=job_template2)
|
job2 = self.create_test_job(job_template=job_template2)
|
||||||
# self.assertEqual(job2.status, 'new')
|
self.assertEqual(job2.status, 'new')
|
||||||
# self.assertTrue(job2.signal_start())
|
self.assertTrue(job2.signal_start())
|
||||||
# job2 = Job.objects.get(pk=job2.pk)
|
job2 = Job.objects.get(pk=job2.pk)
|
||||||
# self.check_job_result(job2, 'successful')
|
self.check_job_result(job2, 'successful')
|
||||||
# Test with extra_vars as YAML (should be converted to JSON in args).
|
# Test with extra_vars as YAML (should be converted to JSON in args).
|
||||||
job_template3 = self.create_test_job_template(extra_vars='abc: 1234')
|
job_template3 = self.create_test_job_template(extra_vars='abc: 1234')
|
||||||
job3 = self.create_test_job(job_template=job_template3)
|
job3 = self.create_test_job(job_template=job_template3)
|
||||||
|
|||||||
Reference in New Issue
Block a user