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

Reenable test for key=value extra vars, remove some unused imports.

This commit is contained in:
Chris Church 2014-12-04 15:42:18 -05:00
parent 680e382a40
commit 12f07e454f
5 changed files with 9 additions and 32 deletions

View File

@ -14,9 +14,6 @@ import uuid
import copy
import random
# PyYAML
import yaml
# Django
from django.conf import settings
from django.db import models, connection

View File

@ -12,9 +12,6 @@ import re
import shlex
import uuid
# PyYAML
import yaml
# Django
from django.conf import settings
from django.db import models
@ -456,18 +453,7 @@ class Job(UnifiedJob, JobOptions):
extra_vars = json.loads(extra_data)
except Exception, e:
logger.warn("Exception deserializing extra vars: " + str(e))
if self.extra_vars is None or self.extra_vars == "":
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 = self.extra_vars_dict
evars.update(extra_vars)
self.update_fields(extra_vars=json.dumps(evars))

View File

@ -13,9 +13,6 @@ import shlex
import urlparse
import uuid
# PyYAML
import yaml
# Django
from django.conf import settings
from django.db import models

View File

@ -11,9 +11,6 @@ import os
import os.path
from StringIO import StringIO
# PyYAML
import yaml
# Django
from django.conf import settings
from django.db import models

View File

@ -887,14 +887,14 @@ class RunJobTest(BaseCeleryTest):
self.assertTrue('"--forks=3"' in job.job_args)
self.assertTrue('"-vv"' in job.job_args)
self.assertTrue('"-e"' in job.job_args)
# Test with extra_vars as key=value (old format).
# TODO: Do we still support this?
# job_template2 = self.create_test_job_template(extra_vars='foo=1')
# job2 = self.create_test_job(job_template=job_template2)
# self.assertEqual(job2.status, 'new')
# self.assertTrue(job2.signal_start())
# job2 = Job.objects.get(pk=job2.pk)
# self.check_job_result(job2, 'successful')
# Test with extra_vars as key=value (old format, still supported by
# -e option to ansible-playbook).
job_template2 = self.create_test_job_template(extra_vars='foo=1')
job2 = self.create_test_job(job_template=job_template2)
self.assertEqual(job2.status, 'new')
self.assertTrue(job2.signal_start())
job2 = Job.objects.get(pk=job2.pk)
self.check_job_result(job2, 'successful')
# Test with extra_vars as YAML (should be converted to JSON in args).
job_template3 = self.create_test_job_template(extra_vars='abc: 1234')
job3 = self.create_test_job(job_template=job_template3)