Merge "Cleanup temp files in tests"
This commit is contained in:
commit
43e63cf6ff
|
@ -229,7 +229,8 @@ class HookDockerCmdTest(common.RunScriptTest):
|
|||
], state_1['args'])
|
||||
|
||||
def test_cleanup_deleted(self):
|
||||
with tempfile.NamedTemporaryFile(delete=False) as f:
|
||||
conf_dir = self.useFixture(fixtures.TempDir()).join()
|
||||
with tempfile.NamedTemporaryFile(dir=conf_dir, delete=False) as f:
|
||||
f.write(json.dumps([self.data]))
|
||||
f.flush()
|
||||
self.env['HEAT_SHELL_CONFIG'] = f.name
|
||||
|
@ -245,7 +246,7 @@ class HookDockerCmdTest(common.RunScriptTest):
|
|||
matchers.Not(matchers.FileExists()))
|
||||
|
||||
# run again with empty config data
|
||||
with tempfile.NamedTemporaryFile(delete=False) as f:
|
||||
with tempfile.NamedTemporaryFile(dir=conf_dir, delete=False) as f:
|
||||
f.write(json.dumps([]))
|
||||
f.flush()
|
||||
self.env['HEAT_SHELL_CONFIG'] = f.name
|
||||
|
@ -275,7 +276,8 @@ class HookDockerCmdTest(common.RunScriptTest):
|
|||
], state_1['args'])
|
||||
|
||||
def test_cleanup_changed(self):
|
||||
with tempfile.NamedTemporaryFile(delete=False) as f:
|
||||
conf_dir = self.useFixture(fixtures.TempDir()).join()
|
||||
with tempfile.NamedTemporaryFile(dir=conf_dir, delete=False) as f:
|
||||
f.write(json.dumps([self.data]))
|
||||
f.flush()
|
||||
self.env['HEAT_SHELL_CONFIG'] = f.name
|
||||
|
@ -293,7 +295,7 @@ class HookDockerCmdTest(common.RunScriptTest):
|
|||
# run again with changed config data
|
||||
new_data = copy.deepcopy(self.data)
|
||||
new_data['config']['web']['image'] = 'yyy'
|
||||
with tempfile.NamedTemporaryFile(delete=False) as f:
|
||||
with tempfile.NamedTemporaryFile(dir=conf_dir, delete=False) as f:
|
||||
f.write(json.dumps([new_data]))
|
||||
f.flush()
|
||||
self.env['HEAT_SHELL_CONFIG'] = f.name
|
||||
|
|
|
@ -55,7 +55,9 @@ class HookHieraTest(common.RunScriptTest):
|
|||
'heat-config-hiera/install.d/hook-hiera.py')
|
||||
|
||||
self.hieradata_dir = self.useFixture(fixtures.TempDir()).join()
|
||||
self.conf = tempfile.NamedTemporaryFile(mode='w', delete=False).name
|
||||
conf_dir = self.useFixture(fixtures.TempDir()).join()
|
||||
self.conf = tempfile.NamedTemporaryFile(
|
||||
dir=conf_dir, mode='w', delete=False).name
|
||||
os.unlink(self.conf)
|
||||
|
||||
self.env = os.environ.copy()
|
||||
|
|
|
@ -17,6 +17,8 @@ import os
|
|||
import tempfile
|
||||
import yaml
|
||||
|
||||
import fixtures
|
||||
|
||||
from tests import common
|
||||
|
||||
log = logging.getLogger('test_hook_json_file')
|
||||
|
@ -31,7 +33,9 @@ class HookJsonFileConfigTest(common.RunScriptTest):
|
|||
'..',
|
||||
'heat-config-json-file/install.d/hook-json-file.py')
|
||||
|
||||
self.conf = tempfile.NamedTemporaryFile(mode='w', delete=False).name
|
||||
conf_dir = self.useFixture(fixtures.TempDir()).join()
|
||||
self.conf = tempfile.NamedTemporaryFile(
|
||||
mode='w', dir=conf_dir, delete=False).name
|
||||
os.unlink(self.conf)
|
||||
|
||||
self.env = os.environ.copy()
|
||||
|
|
|
@ -37,9 +37,10 @@ failure:
|
|||
"""
|
||||
|
||||
slsnotallowed = """
|
||||
install_service:
|
||||
pkg.installed:
|
||||
- name: {{ opts['fooval'] }}
|
||||
default to accept:
|
||||
iptables.set_policy:
|
||||
- chain: INPUT
|
||||
- policy: REJECT
|
||||
"""
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue