Merge branch '4.0' of github.com:Ultimaker/Cura

This commit is contained in:
Jaime van Kessel 2019-01-17 13:42:58 +01:00
commit 15563a756f
7 changed files with 26 additions and 22 deletions

View File

@ -117,7 +117,7 @@ from cura.ObjectsModel import ObjectsModel
from cura.PrinterOutputDevice import PrinterOutputDevice from cura.PrinterOutputDevice import PrinterOutputDevice
from cura.PrinterOutput.NetworkMJPGImage import NetworkMJPGImage from cura.PrinterOutput.NetworkMJPGImage import NetworkMJPGImage
from cura import ApplicationMetadata from cura import ApplicationMetadata, UltimakerCloudAuthentication
from UM.FlameProfiler import pyqtSlot from UM.FlameProfiler import pyqtSlot
from UM.Decorators import override from UM.Decorators import override
@ -132,16 +132,6 @@ if TYPE_CHECKING:
numpy.seterr(all = "ignore") numpy.seterr(all = "ignore")
try:
from cura.CuraVersion import CuraAppDisplayName, CuraVersion, CuraBuildType, CuraDebugMode, CuraSDKVersion # type: ignore
except ImportError:
CuraAppDisplayName = "Ultimaker Cura"
CuraVersion = "master" # [CodeStyle: Reflecting imported value]
CuraBuildType = ""
CuraDebugMode = False
CuraSDKVersion = "6.0.0"
class CuraApplication(QtApplication): class CuraApplication(QtApplication):
# SettingVersion represents the set of settings available in the machine/extruder definitions. # SettingVersion represents the set of settings available in the machine/extruder definitions.
# You need to make sure that this version number needs to be increased if there is any non-backwards-compatible # You need to make sure that this version number needs to be increased if there is any non-backwards-compatible
@ -266,6 +256,14 @@ class CuraApplication(QtApplication):
from cura.CuraPackageManager import CuraPackageManager from cura.CuraPackageManager import CuraPackageManager
self._package_manager_class = CuraPackageManager self._package_manager_class = CuraPackageManager
@pyqtProperty(str, constant=True)
def ultimakerCloudApiRootUrl(self) -> str:
return UltimakerCloudAuthentication.CuraCloudAPIRoot
@pyqtProperty(str, constant = True)
def ultimakerCloudAccountRootUrl(self) -> str:
return UltimakerCloudAuthentication.CuraCloudAccountAPIRoot
# Adds command line options to the command line parser. This should be called after the application is created and # Adds command line options to the command line parser. This should be called after the application is created and
# before the pre-start. # before the pre-start.
def addCommandLineOptions(self): def addCommandLineOptions(self):

View File

@ -15,6 +15,9 @@ from ...src.Cloud.Models.CloudError import CloudError
from .Fixtures import readFixture, parseFixture from .Fixtures import readFixture, parseFixture
from .NetworkManagerMock import NetworkManagerMock from .NetworkManagerMock import NetworkManagerMock
import pytest
pytestmark = pytest.mark.skip("Tests failing due to incorrect paths in patch")
class TestCloudApiClient(TestCase): class TestCloudApiClient(TestCase):
maxDiff = None maxDiff = None
@ -28,7 +31,7 @@ class TestCloudApiClient(TestCase):
self.account.isLoggedIn.return_value = True self.account.isLoggedIn.return_value = True
self.network = NetworkManagerMock() self.network = NetworkManagerMock()
with patch("plugins.UM3NetworkPrinting.src.Cloud.CloudApiClient.QNetworkAccessManager", return_value = self.network): with patch("CloudApiClient.QNetworkAccessManager", return_value = self.network):
self.api = CloudApiClient(self.account, self._errorHandler) self.api = CloudApiClient(self.account, self._errorHandler)
def test_getClusters(self): def test_getClusters(self):

View File

@ -13,6 +13,9 @@ from ...src.Cloud.Models.CloudClusterResponse import CloudClusterResponse
from .Fixtures import readFixture, parseFixture from .Fixtures import readFixture, parseFixture
from .NetworkManagerMock import NetworkManagerMock from .NetworkManagerMock import NetworkManagerMock
import pytest
pytestmark = pytest.mark.skip("Tests failing due to incorrect paths in patch")
class TestCloudOutputDevice(TestCase): class TestCloudOutputDevice(TestCase):
maxDiff = None maxDiff = None
@ -41,7 +44,7 @@ class TestCloudOutputDevice(TestCase):
self.network = NetworkManagerMock() self.network = NetworkManagerMock()
self.account = MagicMock(isLoggedIn=True, accessToken="TestAccessToken") self.account = MagicMock(isLoggedIn=True, accessToken="TestAccessToken")
self.onError = MagicMock() self.onError = MagicMock()
with patch("plugins.UM3NetworkPrinting.src.Cloud.CloudApiClient.QNetworkAccessManager", with patch("CloudApiClient.QNetworkAccessManager",
return_value = self.network): return_value = self.network):
self._api = CloudApiClient(self.account, self.onError) self._api = CloudApiClient(self.account, self.onError)

View File

@ -9,6 +9,9 @@ from ...src.Cloud.CloudOutputDeviceManager import CloudOutputDeviceManager
from .Fixtures import parseFixture, readFixture from .Fixtures import parseFixture, readFixture
from .NetworkManagerMock import NetworkManagerMock, FakeSignal from .NetworkManagerMock import NetworkManagerMock, FakeSignal
import pytest
pytestmark = pytest.mark.skip("Tests failing due to incorrect paths in patch")
class TestCloudOutputDeviceManager(TestCase): class TestCloudOutputDeviceManager(TestCase):
maxDiff = None maxDiff = None
@ -28,10 +31,8 @@ class TestCloudOutputDeviceManager(TestCase):
self.network = NetworkManagerMock() self.network = NetworkManagerMock()
self.timer = MagicMock(timeout = FakeSignal()) self.timer = MagicMock(timeout = FakeSignal())
with patch("plugins.UM3NetworkPrinting.src.Cloud.CloudApiClient.QNetworkAccessManager", with patch("CloudApiClient.QNetworkAccessManager", return_value = self.network), \
return_value = self.network), \ patch("CloudOutputDeviceManager.QTimer", return_value = self.timer):
patch("plugins.UM3NetworkPrinting.src.Cloud.CloudOutputDeviceManager.QTimer",
return_value = self.timer):
self.manager = CloudOutputDeviceManager() self.manager = CloudOutputDeviceManager()
self.clusters_response = parseFixture("getClusters") self.clusters_response = parseFixture("getClusters")
self.network.prepareReply("GET", self.URL, 200, readFixture("getClusters")) self.network.prepareReply("GET", self.URL, 200, readFixture("getClusters"))
@ -114,7 +115,7 @@ class TestCloudOutputDeviceManager(TestCase):
active_machine_mock.setMetaDataEntry.assert_called_with("um_cloud_cluster_id", cluster2["cluster_id"]) active_machine_mock.setMetaDataEntry.assert_called_with("um_cloud_cluster_id", cluster2["cluster_id"])
@patch("plugins.UM3NetworkPrinting.src.Cloud.CloudOutputDeviceManager.Message") @patch("CloudOutputDeviceManager.Message")
def test_api_error(self, message_mock): def test_api_error(self, message_mock):
self.clusters_response = { self.clusters_response = {
"errors": [{"id": "notFound", "title": "Not found!", "http_status": "404", "code": "notFound"}] "errors": [{"id": "notFound", "title": "Not found!", "http_status": "404", "code": "notFound"}]

View File

@ -1,7 +1,6 @@
# Copyright (c) 2018 Ultimaker B.V. # Copyright (c) 2018 Ultimaker B.V.
# Copyright (c) 2018 Ultimaker B.V. # Copyright (c) 2018 Ultimaker B.V.
# Cura is released under the terms of the LGPLv3 or higher. # Cura is released under the terms of the LGPLv3 or higher.
import copy
import io import io
import json import json
from unittest import TestCase, mock from unittest import TestCase, mock
@ -14,7 +13,7 @@ from UM.Application import Application
from cura.Machines.MaterialGroup import MaterialGroup from cura.Machines.MaterialGroup import MaterialGroup
from cura.Machines.MaterialNode import MaterialNode from cura.Machines.MaterialNode import MaterialNode
from plugins.UM3NetworkPrinting.src.SendMaterialJob import SendMaterialJob from ..src.SendMaterialJob import SendMaterialJob
_FILES_MAP = {"generic_pla_white": "/materials/generic_pla_white.xml.fdm_material", _FILES_MAP = {"generic_pla_white": "/materials/generic_pla_white.xml.fdm_material",
"generic_pla_black": "/materials/generic_pla_black.xml.fdm_material", "generic_pla_black": "/materials/generic_pla_black.xml.fdm_material",

View File

@ -16,7 +16,7 @@ Row
width: UM.Theme.getSize("account_button").width width: UM.Theme.getSize("account_button").width
height: UM.Theme.getSize("account_button").height height: UM.Theme.getSize("account_button").height
text: catalog.i18nc("@button", "Create account") text: catalog.i18nc("@button", "Create account")
onClicked: Qt.openUrlExternally("https://account.ultimaker.com/app/create") onClicked: Qt.openUrlExternally(CuraApplication.ultimakerCloudAccountRootUrl + "/app/create")
fixedWidthMode: true fixedWidthMode: true
} }

View File

@ -16,7 +16,7 @@ Row
width: UM.Theme.getSize("account_button").width width: UM.Theme.getSize("account_button").width
height: UM.Theme.getSize("account_button").height height: UM.Theme.getSize("account_button").height
text: catalog.i18nc("@button", "Manage account") text: catalog.i18nc("@button", "Manage account")
onClicked: Qt.openUrlExternally("https://account.ultimaker.com") onClicked: Qt.openUrlExternally(CuraApplication.ultimakerCloudAccountRootUrl)
fixedWidthMode: true fixedWidthMode: true
} }