From 931018b877cba91b82d1b969e8e31d8ab3bebcca Mon Sep 17 00:00:00 2001 From: ziajka Date: Tue, 27 Jun 2017 11:11:07 +0200 Subject: [PATCH] Fix passing tests --- gns3server/compute/iou/iou_vm.py | 3 ++- gns3server/controller/node.py | 4 +++- gns3server/controller/project.py | 1 + tests/controller/test_project.py | 10 +++++----- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/gns3server/compute/iou/iou_vm.py b/gns3server/compute/iou/iou_vm.py index c99f18e6..4d12122c 100644 --- a/gns3server/compute/iou/iou_vm.py +++ b/gns3server/compute/iou/iou_vm.py @@ -207,7 +207,8 @@ class IOUVM(BaseNode): "nvram": self._nvram, "l1_keepalives": self._l1_keepalives, "use_default_iou_values": self._use_default_iou_values, - "command_line": self.command_line} + "command_line": self.command_line, + "application_id": self.application_id} # return the relative path if the IOU image is in the images_path directory iou_vm_info["path"] = self.manager.get_relative_image_path(self.path) diff --git a/gns3server/controller/node.py b/gns3server/controller/node.py index bfff2624..f6575b7a 100644 --- a/gns3server/controller/node.py +++ b/gns3server/controller/node.py @@ -66,7 +66,7 @@ class Node: self.name = name self._console = None self._console_type = None - self._properties = {} + self._properties = None self._command_line = None self._node_directory = None self._status = "stopped" @@ -88,6 +88,8 @@ class Node: # This properties will be recompute ignore_properties = ("width", "height") + self.properties = kwargs.pop('properties', {}) + # Update node properties with additional elements for prop in kwargs: if prop not in ignore_properties: diff --git a/gns3server/controller/project.py b/gns3server/controller/project.py index fc6e8dac..d1d8935f 100644 --- a/gns3server/controller/project.py +++ b/gns3server/controller/project.py @@ -354,6 +354,7 @@ class Project: return self._nodes[node_id] if node_type == "iou" and 'application_id' not in kwargs.keys(): + kwargs['application_id'] = get_next_application_id(self._nodes.values()) node = Node(self, compute, name, node_id=node_id, node_type=node_type, **kwargs) diff --git a/tests/controller/test_project.py b/tests/controller/test_project.py index d75d1f79..c09a9e55 100644 --- a/tests/controller/test_project.py +++ b/tests/controller/test_project.py @@ -361,7 +361,7 @@ def test_delete_drawing(async_run, project, controller): assert len(project._drawings) == 0 -def test_clean_pcictures(async_run, project, controller): +def test_clean_pictures(async_run, project, controller): """ When a project is close old pictures should be removed """ @@ -589,13 +589,13 @@ def test_add_iou_node_and_check_if_gets_application_id(project, async_run): # tests if get_next_application_id is called with patch('gns3server.controller.project.get_next_application_id', return_value=222) as mocked_get_app_id: - results = async_run(project.add_node( + node = async_run(project.add_node( compute, "test", None, node_type="iou", properties={"startup_config": "test.cfg"})) assert mocked_get_app_id.called - assert results.properties['application_id'] == 222 + assert node.properties['application_id'] == 222 # tests if we can send property and it will be used - results = async_run(project.add_node( + node = async_run(project.add_node( compute, "test", None, node_type="iou", application_id=333, properties={"startup_config": "test.cfg"})) assert mocked_get_app_id.called - assert results.properties['application_id'] == 333 \ No newline at end of file + assert node.properties['application_id'] == 333 \ No newline at end of file