diff options
author | Jaime van Kessel <nallath@gmail.com> | 2019-08-22 15:32:33 +0300 |
---|---|---|
committer | Jaime van Kessel <nallath@gmail.com> | 2019-08-22 15:32:33 +0300 |
commit | 89260891e6cc156358a2e0ce5fb8e0a2e31cfb74 (patch) | |
tree | 7cf5740778951a48fe76a2fbfedc49bc5211f2f2 /tests/PrinterOutput | |
parent | 34c3a0474464f621fa5d35e7f5a9bbe09f4503ac (diff) |
Add tests for the available configurations
CURA-6732
Diffstat (limited to 'tests/PrinterOutput')
-rw-r--r-- | tests/PrinterOutput/Models/TestPrinterOutputModel.py | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/PrinterOutput/Models/TestPrinterOutputModel.py b/tests/PrinterOutput/Models/TestPrinterOutputModel.py index 8136e670b7..9848e0a5fa 100644 --- a/tests/PrinterOutput/Models/TestPrinterOutputModel.py +++ b/tests/PrinterOutput/Models/TestPrinterOutputModel.py @@ -5,6 +5,7 @@ from unittest.mock import MagicMock import pytest from cura.PrinterOutput.Models.PrintJobOutputModel import PrintJobOutputModel +from cura.PrinterOutput.Models.PrinterConfigurationModel import PrinterConfigurationModel from cura.PrinterOutput.Models.PrinterOutputModel import PrinterOutputModel from cura.PrinterOutput.Peripheral import Peripheral @@ -103,3 +104,46 @@ def test_peripherals(): model.removePeripheral(peripheral) assert model.peripheralsChanged.emit.call_count == 3 assert model.peripherals == "test2" + + +def test_availableConfigurations_addConfiguration(): + model = PrinterOutputModel(MagicMock()) + + configuration = MagicMock(spec = PrinterConfigurationModel) + + model.addAvailableConfiguration(configuration) + assert model.availableConfigurations == [configuration] + + +def test_availableConfigurations_addConfigTwice(): + model = PrinterOutputModel(MagicMock()) + + configuration = MagicMock(spec=PrinterConfigurationModel) + + model.setAvailableConfigurations([configuration]) + assert model.availableConfigurations == [configuration] + + # Adding it again should not have any effect + model.addAvailableConfiguration(configuration) + assert model.availableConfigurations == [configuration] + + +def test_availableConfigurations_removeConfig(): + model = PrinterOutputModel(MagicMock()) + + configuration = MagicMock(spec=PrinterConfigurationModel) + + model.addAvailableConfiguration(configuration) + model.removeAvailableConfiguration(configuration) + assert model.availableConfigurations == [] + + +def test_removeAlreadyRemovedConfiguration(): + model = PrinterOutputModel(MagicMock()) + + configuration = MagicMock(spec=PrinterConfigurationModel) + model.availableConfigurationsChanged = MagicMock() + model.removeAvailableConfiguration(configuration) + assert model.availableConfigurationsChanged.emit.call_count == 0 + assert model.availableConfigurations == [] + |