Browse Source

Test fixes, not working yet

ChrisTerBeke 5 years ago
parent
commit
882352c99d

+ 2 - 2
cura/PrinterOutput/Models/ExtruderConfigurationModel.py

@@ -25,7 +25,7 @@ class ExtruderConfigurationModel(QObject):
         return self._position
 
     def setMaterial(self, material: Optional[MaterialOutputModel]) -> None:
-        if self._hotend_id != material:
+        if self._material != material:
             self._material = material
             self.extruderConfigurationChanged.emit()
 
@@ -33,7 +33,7 @@ class ExtruderConfigurationModel(QObject):
     def activeMaterial(self) -> Optional[MaterialOutputModel]:
         return self._material
 
-    @pyqtProperty(QObject, fset=setMaterial, notify=extruderConfigurationChanged)
+    @pyqtProperty(QObject, fset = setMaterial, notify = extruderConfigurationChanged)
     def material(self) -> Optional[MaterialOutputModel]:
         return self._material
 

+ 8 - 1
tests/PrinterOutput/TestPrinterOutputDevice.py

@@ -63,6 +63,12 @@ def test_uniqueConfigurations(printer_output_device):
     # Once the type of printer is set, it's active configuration counts as being set.
     # In that case, that should also be added to the list of available configurations
     printer.updateType("blarg!")
+    loaded_material = MaterialOutputModel(guid = "", type = "PLA", color = "Blue", brand = "Generic", name = "Blue PLA")
+    loaded_left_extruder = ExtruderConfigurationModel(0)
+    loaded_left_extruder.setMaterial(loaded_material)
+    loaded_right_extruder = ExtruderConfigurationModel(1)
+    loaded_right_extruder.setMaterial(loaded_material)
+    printer.printerConfiguration.setExtruderConfigurations([loaded_left_extruder, loaded_right_extruder])
     assert printer_output_device.uniqueConfigurations == [configuration, printer.printerConfiguration]
 
 
@@ -72,10 +78,11 @@ def test_uniqueConfigurations_empty_is_filtered_out(printer_output_device):
     printer_output_device._printers = [printer]
     printer_output_device._onPrintersChanged()
 
+    printer.updateType("blarg!")
     empty_material = MaterialOutputModel(guid = "", type = "empty", color = "empty", brand = "Generic", name = "Empty")
     empty_left_extruder = ExtruderConfigurationModel(0)
     empty_left_extruder.setMaterial(empty_material)
     empty_right_extruder = ExtruderConfigurationModel(1)
     empty_right_extruder.setMaterial(empty_material)
     printer.printerConfiguration.setExtruderConfigurations([empty_left_extruder, empty_right_extruder])
-    assert printer_output_device.uniqueConfiguration == []
+    assert printer_output_device.uniqueConfigurations == []