Fix dynamips node creation error

This commit is contained in:
Julien Duponchelle 2017-05-16 10:49:45 +02:00
parent 5c5caf8418
commit e9fef928b0
No known key found for this signature in database
GPG Key ID: CE8B29639E07F5E8
2 changed files with 20 additions and 2 deletions

View File

@ -98,7 +98,8 @@ class Node:
log.critical("Can't set attribute %s", prop)
raise e
else:
self.properties[prop] = kwargs[prop]
if prop not in self.CONTROLLER_ONLY_PROPERTIES and kwargs[prop] is not None and kwargs[prop] != "":
self.properties[prop] = kwargs[prop]
if self._symbol is None:
self.symbol = ":/symbols/computer.svg"

View File

@ -83,7 +83,7 @@ def test_name(compute, project):
def test_vmname(compute, project):
"""
Additionnal properties should add to the properties
Additionnal properties should be add to the properties
field
"""
node = Node(project, compute, "PC",
@ -93,6 +93,23 @@ def test_vmname(compute, project):
assert node.properties["vmname"] == "test"
def test_empty_properties(compute, project):
"""
Empty properties need to be ignored
"""
node = Node(project, compute, "PC",
node_id=str(uuid.uuid4()),
node_type="virtualbox",
aa="",
bb=None,
category=2,
cc="xx")
assert "aa" not in node.properties
assert "bb" not in node.properties
assert "cc" in node.properties
assert "category" not in node.properties # Controller only
def test_eq(compute, project, node, controller):
assert node == Node(project, compute, "demo1", node_id=node.id, node_type="qemu")
assert node != "a"