Add tests for dicts in VR

This commit is contained in:
Łukasz Oleś 2015-12-07 13:27:40 +01:00
parent fdd5c3da1b
commit bb989fd291
2 changed files with 34 additions and 0 deletions

View File

@ -0,0 +1,9 @@
id: simple_resource_with_list
resources:
- id: res1
from: {resource_path}
values:
ip: '10.0.0.3'
servers:
a: 1
b: 2

View File

@ -95,6 +95,22 @@ def test_create_virtual_resource_with_list(tmpdir):
assert res.args['servers'] == [1, 2]
def test_create_virtual_resource_with_dict(tmpdir):
base_path = os.path.join(
os.path.dirname(os.path.realpath(__file__)),
'resource_fixtures')
vr_tmpl_path = os.path.join(base_path, 'resource_with_dict.yaml.tmpl')
base_resource_path = os.path.join(base_path, 'base_service')
with open(vr_tmpl_path) as f:
vr_data = f.read().format(resource_path=base_resource_path)
vr_file = tmpdir.join('base.yaml')
vr_file.write(vr_data)
resources = vr.create('base', str(vr_file))
assert len(resources) == 1
res = resources[0]
assert res.args['servers'] == {'a': 1, 'b': 2}
def test_update(tmpdir):
# XXX: make helper for it
base_path = os.path.join(
@ -167,6 +183,15 @@ def test_parse_connection():
assert correct_connection == connection
def test_parse_dict_input():
correct_connections = [{'child_input': 'env:host',
'events': None,
'parent': 'node1',
'parent_input': 'ip'}]
connections, assigments = vr.parse_dict_input('env', {'host': 'node1::ip'})
assert correct_connections == connections
def test_parse_connection_disable_events():
correct_connection = {'child_input': 'ip',
'parent': 'node1',