mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-14 18:27:51 -06:00
Add tests for the available configurations
CURA-6732
This commit is contained in:
parent
34c3a04744
commit
89260891e6
1 changed files with 44 additions and 0 deletions
|
@ -5,6 +5,7 @@ from unittest.mock import MagicMock
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from cura.PrinterOutput.Models.PrintJobOutputModel import PrintJobOutputModel
|
from cura.PrinterOutput.Models.PrintJobOutputModel import PrintJobOutputModel
|
||||||
|
from cura.PrinterOutput.Models.PrinterConfigurationModel import PrinterConfigurationModel
|
||||||
from cura.PrinterOutput.Models.PrinterOutputModel import PrinterOutputModel
|
from cura.PrinterOutput.Models.PrinterOutputModel import PrinterOutputModel
|
||||||
from cura.PrinterOutput.Peripheral import Peripheral
|
from cura.PrinterOutput.Peripheral import Peripheral
|
||||||
|
|
||||||
|
@ -103,3 +104,46 @@ def test_peripherals():
|
||||||
model.removePeripheral(peripheral)
|
model.removePeripheral(peripheral)
|
||||||
assert model.peripheralsChanged.emit.call_count == 3
|
assert model.peripheralsChanged.emit.call_count == 3
|
||||||
assert model.peripherals == "test2"
|
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 == []
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue