Send node.updated notif only if object changed

This commit is contained in:
Julien Duponchelle
2016-06-30 18:29:17 +02:00
parent 758a427a76
commit fe7bcae6a1
3 changed files with 24 additions and 11 deletions

View File

@ -186,16 +186,25 @@ def test_update_properties(node, compute, project, async_run, controller):
controller._notification.emit.assert_called_with("node.updated", node_notif)
def test_update_only_controller(node, compute, project, async_run):
def test_update_only_controller(node, controller, compute, project, async_run):
"""
When updating property used only on controller we don't need to
call the compute
"""
compute.put = AsyncioMagicMock()
controller._notification = AsyncioMagicMock()
async_run(node.update(x=42))
assert not compute.put.called
assert node.x == 42
controller._notification.emit.assert_called_with("node.updated", node.__json__())
# If nothing change a second notif should not be send
controller._notification = AsyncioMagicMock()
async_run(node.update(x=42))
assert not controller._notification.emit.called
def test_update_no_changes(node, compute, project, async_run):