From 12a4a5e9f54ba62b6c2eb1f6df8e1a28c8441506 Mon Sep 17 00:00:00 2001 From: Marijn Dee Date: Fri, 21 Dec 2018 15:06:02 +0100 Subject: [PATCH] Fixing the rest of the automatic test failures --- ...CloudClusterPrintJobConfigurationChange.py | 5 ++- .../Models/CloudClusterPrintJobStatus.py | 35 +++++++++---------- .../Cloud/Models/CloudClusterPrinterStatus.py | 4 +-- 3 files changed, 21 insertions(+), 23 deletions(-) diff --git a/plugins/UM3NetworkPrinting/src/Cloud/Models/CloudClusterPrintJobConfigurationChange.py b/plugins/UM3NetworkPrinting/src/Cloud/Models/CloudClusterPrintJobConfigurationChange.py index 6c02972757..9ff4154666 100644 --- a/plugins/UM3NetworkPrinting/src/Cloud/Models/CloudClusterPrintJobConfigurationChange.py +++ b/plugins/UM3NetworkPrinting/src/Cloud/Models/CloudClusterPrintJobConfigurationChange.py @@ -15,9 +15,8 @@ class CloudClusterPrintJobConfigurationChange(BaseCloudModel): # \param origin_id: Original/current material guid or hotend id # \param target_name: Target material name or hotend id # \param origin_name: Original/current material name or hotend id - def __init__(self, type_of_change: Optional[str] = None, index: Optional[int] = None, - target_id: Optional[str] = None,origin_id: Optional[str] = None, - target_name: Optional[str] = None,origin_name: Optional[str] = None, + def __init__(self, type_of_change: str, target_id: str, origin_id: str, + index: Optional[int] = None, target_name: Optional[str] = None, origin_name: Optional[str] = None, **kwargs) -> None: self.type_of_change = type_of_change self.index = index diff --git a/plugins/UM3NetworkPrinting/src/Cloud/Models/CloudClusterPrintJobStatus.py b/plugins/UM3NetworkPrinting/src/Cloud/Models/CloudClusterPrintJobStatus.py index b1672f362e..5d62471710 100644 --- a/plugins/UM3NetworkPrinting/src/Cloud/Models/CloudClusterPrintJobStatus.py +++ b/plugins/UM3NetworkPrinting/src/Cloud/Models/CloudClusterPrintJobStatus.py @@ -55,7 +55,8 @@ class CloudClusterPrintJobStatus(BaseCloudModel): printed_on_uuid: Optional[str] = None, configuration_changes_required: List[ Union[Dict[str, Any], CloudClusterPrintJobConfigurationChange]] = None, - build_plate: Optional[str] = None, compatible_machine_families: List[str] = None, + build_plate: Union[Dict[str, Any], CloudClusterBuildPlate] = None, + compatible_machine_families: List[str] = None, impediments_to_printing: List[Union[Dict[str, Any], CloudClusterPrintJobImpediment]] = None, **kwargs) -> None: self.assigned_to = assigned_to @@ -76,17 +77,14 @@ class CloudClusterPrintJobStatus(BaseCloudModel): self.uuid = uuid self.deleted_at = deleted_at self.printed_on_uuid = printed_on_uuid - if configuration_changes_required: - self.configuration_changes_required = self.parseModels(CloudClusterPrintJobConfigurationChange, - configuration_changes_required) - else: - self.configuration_changes_required = [] - self.build_plate = self.parseModel(CloudClusterBuildPlate, build_plate) - self.compatible_machine_families = compatible_machine_families - if impediments_to_printing: - self.impediments_to_printing = self.parseModels(CloudClusterPrintJobImpediment, impediments_to_printing) - else: - self.impediments_to_printing = [] + + self.configuration_changes_required = self.parseModels(CloudClusterPrintJobConfigurationChange, + configuration_changes_required) \ + if configuration_changes_required else [] + self.build_plate = self.parseModel(CloudClusterBuildPlate, build_plate) if build_plate else None + self.compatible_machine_families = compatible_machine_families if compatible_machine_families else [] + self.impediments_to_printing = self.parseModels(CloudClusterPrintJobImpediment, impediments_to_printing) \ + if impediments_to_printing else [] super().__init__(**kwargs) @@ -120,7 +118,8 @@ class CloudClusterPrintJobStatus(BaseCloudModel): status_set_by_impediment = False for impediment in self.impediments_to_printing: - if impediment.severity == "UNFIXABLE": # TODO: impediment.severity is defined as int, this will not work, is there a translation? + # TODO: impediment.severity is defined as int, this will not work, is there a translation? + if impediment.severity == "UNFIXABLE": status_set_by_impediment = True model.updateState("error") break @@ -130,8 +129,8 @@ class CloudClusterPrintJobStatus(BaseCloudModel): model.updateConfigurationChanges( [ConfigurationChangeModel( - type_of_change=change.type_of_change, - index=change.index, - target_name=change.target_name, - origin_name=change.origin_name) - for change in self.configuration_changes_required]) + type_of_change = change.type_of_change, + index = change.index if change.index else 0, + target_name = change.target_name if change.target_name else "", + origin_name = change.origin_name if change.origin_name else "") + for change in self.configuration_changes_required]) diff --git a/plugins/UM3NetworkPrinting/src/Cloud/Models/CloudClusterPrinterStatus.py b/plugins/UM3NetworkPrinting/src/Cloud/Models/CloudClusterPrinterStatus.py index 23409a761d..a8165ff69c 100644 --- a/plugins/UM3NetworkPrinting/src/Cloud/Models/CloudClusterPrinterStatus.py +++ b/plugins/UM3NetworkPrinting/src/Cloud/Models/CloudClusterPrinterStatus.py @@ -33,7 +33,7 @@ class CloudClusterPrinterStatus(BaseCloudModel): configuration: List[Union[Dict[str, Any], CloudClusterPrintCoreConfiguration]], reserved_by: Optional[str] = None, maintenance_required: Optional[bool] = None, firmware_update_status: Optional[str] = None, latest_available_firmware: Optional[str] = None, - build_plate: Optional[str] = None, **kwargs) -> None: + build_plate: Union[Dict[str, Any], CloudClusterBuildPlate] = None, **kwargs) -> None: self.configuration = self.parseModels(CloudClusterPrintCoreConfiguration, configuration) self.enabled = enabled @@ -48,7 +48,7 @@ class CloudClusterPrinterStatus(BaseCloudModel): self.maintenance_required = maintenance_required self.firmware_update_status = firmware_update_status self.latest_available_firmware = latest_available_firmware - self.build_plate = self.parseModel(CloudClusterBuildPlate, build_plate) + self.build_plate = self.parseModel(CloudClusterBuildPlate, build_plate) if build_plate else None super().__init__(**kwargs) ## Creates a new output model.