mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-08 07:27:29 -06:00
Move ConfigurationModel into cura.UI module
This commit is contained in:
parent
69eb381f10
commit
e555f7da68
9 changed files with 12 additions and 12 deletions
|
@ -1,45 +0,0 @@
|
|||
|
||||
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
import pytest
|
||||
|
||||
from cura.PrinterOutput.ConfigurationModel import ConfigurationModel
|
||||
from cura.UI.ExtruderConfigurationModel import ExtruderConfigurationModel
|
||||
|
||||
test_validate_data_get_set = [
|
||||
{"attribute": "extruderConfigurations", "value": [ExtruderConfigurationModel()]},
|
||||
{"attribute": "buildplateConfiguration", "value": "BHDHAHHADAD"},
|
||||
{"attribute": "printerType", "value": ":(", "check_signal": False},
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.parametrize("data", test_validate_data_get_set)
|
||||
def test_getAndSet(data):
|
||||
model = ConfigurationModel()
|
||||
|
||||
# Convert the first letter into a capital
|
||||
attribute = list(data["attribute"])
|
||||
attribute[0] = attribute[0].capitalize()
|
||||
attribute = "".join(attribute)
|
||||
|
||||
# mock the correct emit
|
||||
model.configurationChanged = MagicMock()
|
||||
signal = model.configurationChanged
|
||||
|
||||
# Attempt to set the value
|
||||
getattr(model, "set" + attribute)(data["value"])
|
||||
|
||||
# Check if signal fired.
|
||||
if data.get("check_signal", True):
|
||||
assert signal.emit.call_count == 1
|
||||
|
||||
# Ensure that the value got set
|
||||
assert getattr(model, data["attribute"]) == data["value"]
|
||||
|
||||
# Attempt to set the value again
|
||||
getattr(model, "set" + attribute)(data["value"])
|
||||
|
||||
# The signal should not fire again
|
||||
if data.get("check_signal", True):
|
||||
assert signal.emit.call_count == 1
|
Loading…
Add table
Add a link
Reference in a new issue