Merge pull request #473 from AlanCoding/test_fix_exc

fix test fallout from 321 merge
This commit is contained in:
Alan Rominger
2017-10-19 16:05:01 -04:00
committed by GitHub
3 changed files with 6 additions and 16 deletions

View File

@@ -678,19 +678,11 @@ class BaseTask(LogErrorsTask):
def build_inventory(self, instance, **kwargs): def build_inventory(self, instance, **kwargs):
path = os.path.join(kwargs['private_data_dir'], 'inventory') path = os.path.join(kwargs['private_data_dir'], 'inventory')
if not os.path.exists(path): with open(path, 'w') as f:
with open(path, 'w') as f: json_data = json.dumps(instance.inventory.get_script_data(hostvars=True))
json_data = json.dumps(instance.inventory.get_script_data(hostvars=True)) f.write('#! /usr/bin/env python\n# -*- coding: utf-8 -*-\nprint """%s"""\n' % json_data)
f.write('#! /usr/bin/env python\n# -*- coding: utf-8 -*-\nprint """%s"""\n' % json_data) os.chmod(path, stat.S_IRUSR | stat.S_IXUSR)
os.chmod(path, stat.S_IRUSR | stat.S_IXUSR) return path
return path
else:
# work around an inventory caching bug in Ansible 2.4.0
# see: https://github.com/ansible/ansible/pull/30817
# see: https://github.com/ansible/awx/issues/246
inventory_script = tempfile.mktemp(suffix='.awxrest.py', dir=kwargs['private_data_dir'])
shutil.copy(plugin, inventory_script)
return inventory_script
def build_args(self, instance, **kwargs): def build_args(self, instance, **kwargs):
raise NotImplementedError raise NotImplementedError

View File

@@ -1,7 +1,5 @@
import tempfile import tempfile
import pytest
import json import json
import tempfile
import pytest import pytest

View File

@@ -268,7 +268,7 @@ class TestGenericRun(TestJobExecution):
self.task.run(self.pk) self.task.run(self.pk)
for c in [ for c in [
mock.call(self.pk, execution_node=settings.CLUSTER_HOST_ID, status='running'), mock.call(self.pk, execution_node=settings.CLUSTER_HOST_ID, status='running'),
mock.call(self.pk, output_replacements=[], result_traceback=mock.ANY, status='canceled') mock.call(self.pk, status='canceled')
]: ]:
assert c in self.task.update_model.call_args_list assert c in self.task.update_model.call_args_list