Test subhash

This commit is contained in:
Clint Byrum 2013-03-15 00:19:34 -07:00
parent bbb887decd
commit 8107f6ef8c
1 changed files with 21 additions and 0 deletions

View File

@ -22,6 +22,16 @@ CONFIG = {
}
}
# config for example tree - with subhash
CONFIG_SUBHASH = {
"OpenStack::Config": {
"x": "foo",
"database": {
"url": "sqlite:///blah"
}
}
}
# expected output for example tree
OUTPUT = {
"/etc/glance/script.conf": "foo\n",
@ -51,6 +61,17 @@ def test_install_config():
assert os.path.exists(full_path)
assert_equal( open(full_path).read(), contents )
def test_install_config_subhash():
t = tempfile.NamedTemporaryFile()
t.write(json.dumps(CONFIG_SUBHASH))
t.flush()
tmpdir = tempfile.mkdtemp()
install_config(t.name, TEMPLATES, tmpdir, False, 'OpenStack::Config')
for path, contents in OUTPUT.items():
full_path = os.path.join(tmpdir, path[1:])
assert os.path.exists(full_path)
assert_equal( open(full_path).read(), contents )
def test_print_key():
t = tempfile.NamedTemporaryFile()
t.write(json.dumps(CONFIG))