From d758189aafe809397a6caa9616a09e41bb5ef251 Mon Sep 17 00:00:00 2001 From: Ian Paschal Date: Tue, 5 Mar 2019 09:28:18 +0100 Subject: [PATCH] Adapt tests to manual IP connection Contributes to CL-1266 --- .../tests/Cloud/TestCloudOutputDevice.py | 12 ++++++++++-- .../tests/Cloud/TestCloudOutputDeviceManager.py | 14 ++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/plugins/UM3NetworkPrinting/tests/Cloud/TestCloudOutputDevice.py b/plugins/UM3NetworkPrinting/tests/Cloud/TestCloudOutputDevice.py index c4d891302e..6ba6436694 100644 --- a/plugins/UM3NetworkPrinting/tests/Cloud/TestCloudOutputDevice.py +++ b/plugins/UM3NetworkPrinting/tests/Cloud/TestCloudOutputDevice.py @@ -22,6 +22,7 @@ class TestCloudOutputDevice(TestCase): HOST_NAME = "ultimakersystem-ccbdd30044ec" HOST_GUID = "e90ae0ac-1257-4403-91ee-a44c9b7e8050" HOST_VERSION = "5.2.0" + HOST_INTERNAL_IP = "10.183.0.139" STATUS_URL = "{}/connect/v1/clusters/{}/status".format(CuraCloudAPIRoot, CLUSTER_ID) PRINT_URL = "{}/connect/v1/clusters/{}/print/{}".format(CuraCloudAPIRoot, CLUSTER_ID, JOB_ID) @@ -36,8 +37,15 @@ class TestCloudOutputDevice(TestCase): for patched_method in self.patches: patched_method.start() - self.cluster = CloudClusterResponse(self.CLUSTER_ID, self.HOST_GUID, self.HOST_NAME, is_online=True, - status="active", host_version=self.HOST_VERSION) + self.cluster = CloudClusterResponse( + self.CLUSTER_ID, + self.HOST_GUID, + self.HOST_NAME, + is_online=True, + status="active", + host_internal_ip=self.HOST_INTERNAL_IP, + host_version=self.HOST_VERSION + ) self.network = NetworkManagerMock() self.account = MagicMock(isLoggedIn=True, accessToken="TestAccessToken") diff --git a/plugins/UM3NetworkPrinting/tests/Cloud/TestCloudOutputDeviceManager.py b/plugins/UM3NetworkPrinting/tests/Cloud/TestCloudOutputDeviceManager.py index e24ca1694e..b34943c613 100644 --- a/plugins/UM3NetworkPrinting/tests/Cloud/TestCloudOutputDeviceManager.py +++ b/plugins/UM3NetworkPrinting/tests/Cloud/TestCloudOutputDeviceManager.py @@ -113,6 +113,20 @@ class TestCloudOutputDeviceManager(TestCase): active_machine_mock.setMetaDataEntry.assert_called_with("um_cloud_cluster_id", cluster2["cluster_id"]) + def test_device_connects_by_local_ip_address(self): + active_machine_mock = self.app.getGlobalContainerStack.return_value + + cluster1, cluster2 = self.clusters_response["data"] + network_key = cluster2["host_internal_ip"] + active_machine_mock.getMetaDataEntry.side_effect = {"um_network_key": network_key}.get + + self._loadData() + + self.assertIsNone(self.device_manager.getOutputDevice(cluster1["cluster_id"])) + self.assertTrue(self.device_manager.getOutputDevice(cluster2["cluster_id"]).isConnected()) + + active_machine_mock.setMetaDataEntry.assert_called_with("um_cloud_cluster_id", cluster2["cluster_id"]) + @patch.object(CloudOutputDeviceManager, "Message") def test_api_error(self, message_mock): self.clusters_response = {