From 652d5788c3a83e16217692e48ffd1c246327443a Mon Sep 17 00:00:00 2001 From: grossmj Date: Thu, 9 Aug 2018 18:14:38 +0700 Subject: [PATCH] Fix tests. --- tests/controller/test_node.py | 2 ++ tests/controller/test_project.py | 9 +++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/tests/controller/test_node.py b/tests/controller/test_node.py index 0d0489fe..8bcfce87 100644 --- a/tests/controller/test_node.py +++ b/tests/controller/test_node.py @@ -122,6 +122,7 @@ def test_json(node, compute): "compute_id": str(compute.id), "project_id": node.project.id, "node_id": node.id, + "appliance_id": None, "node_type": node.node_type, "name": "demo", "console": node.console, @@ -157,6 +158,7 @@ def test_json(node, compute): assert node.__json__(topology_dump=True) == { "compute_id": str(compute.id), "node_id": node.id, + "appliance_id": None, "node_type": node.node_type, "name": "demo", "console": node.console, diff --git a/tests/controller/test_project.py b/tests/controller/test_project.py index 5a5b0a64..7dda634f 100644 --- a/tests/controller/test_project.py +++ b/tests/controller/test_project.py @@ -18,6 +18,7 @@ import os import sys +import uuid import pytest import aiohttp import zipstream @@ -211,7 +212,7 @@ def test_add_node_from_appliance(async_run, controller): compute.id = "local" project = Project(controller=controller, name="Test") controller._notification = MagicMock() - controller._appliances["fakeid"] = Appliance("fakeid", { + appliance = Appliance(str(uuid.uuid4()), { "server": "local", "name": "Test", "default_name_format": "{name}-{0}", @@ -219,15 +220,15 @@ def test_add_node_from_appliance(async_run, controller): "properties": { "a": 1 } - }) + controller._appliances[appliance.id] = appliance controller._computes["local"] = compute response = MagicMock() response.json = {"console": 2048} compute.post = AsyncioMagicMock(return_value=response) - node = async_run(project.add_node_from_appliance("fakeid", x=23, y=12)) + node = async_run(project.add_node_from_appliance(appliance.id, x=23, y=12)) compute.post.assert_any_call('/projects', data={ "name": project._name, @@ -244,7 +245,7 @@ def test_add_node_from_appliance(async_run, controller): controller.notification.emit.assert_any_call("node.created", node.__json__()) # Make sure we can call twice the node creation - node = async_run(project.add_node_from_appliance("fakeid", x=13, y=12)) + node = async_run(project.add_node_from_appliance(appliance.id, x=13, y=12)) compute.post.assert_any_call('/projects/{}/vpcs/nodes'.format(project.id), data={'node_id': node.id, 'name': 'Test-2',