diff options
author | Lipu Fei <lipu.fei815@gmail.com> | 2019-03-20 11:25:37 +0300 |
---|---|---|
committer | Lipu Fei <lipu.fei815@gmail.com> | 2019-03-20 11:27:23 +0300 |
commit | e30104ff7fa541f10ac333ae9df684acf6784656 (patch) | |
tree | c4269d2bded3ecb8a5d02c796c8d3ae60bd56293 /tests/PrinterOutput | |
parent | 1f5cf62a7c2801204a7a3abd3ef1b8b5c0fbbe39 (diff) |
Move PrintJobOutputModel into cura.UI module
Diffstat (limited to 'tests/PrinterOutput')
-rw-r--r-- | tests/PrinterOutput/TestPrintJobOutputModel.py | 78 | ||||
-rw-r--r-- | tests/PrinterOutput/TestPrinterOutputModel.py | 2 |
2 files changed, 1 insertions, 79 deletions
diff --git a/tests/PrinterOutput/TestPrintJobOutputModel.py b/tests/PrinterOutput/TestPrintJobOutputModel.py deleted file mode 100644 index 658cff7a7e..0000000000 --- a/tests/PrinterOutput/TestPrintJobOutputModel.py +++ /dev/null @@ -1,78 +0,0 @@ -from unittest.mock import MagicMock - -import pytest - -from cura.PrinterOutput.ConfigurationModel import ConfigurationModel -from cura.PrinterOutput.PrintJobOutputModel import PrintJobOutputModel -from cura.PrinterOutput.PrinterOutputModel import PrinterOutputModel - -test_validate_data_get_set = [ - {"attribute": "compatibleMachineFamilies", "value": ["yay"]}, -] - -test_validate_data_get_update = [ - {"attribute": "configuration", "value": ConfigurationModel()}, - {"attribute": "owner", "value": "WHOO"}, - {"attribute": "assignedPrinter", "value": PrinterOutputModel(MagicMock())}, - {"attribute": "key", "value": "YAY"}, - {"attribute": "name", "value": "Turtles"}, - {"attribute": "timeTotal", "value": 10}, - {"attribute": "timeElapsed", "value": 20}, - {"attribute": "state", "value": "BANANNA!"}, -] - - -@pytest.mark.parametrize("data", test_validate_data_get_set) -def test_getAndSet(data): - model = PrintJobOutputModel(MagicMock()) - - # Convert the first letter into a capital - attribute = list(data["attribute"]) - attribute[0] = attribute[0].capitalize() - attribute = "".join(attribute) - - # mock the correct emit - setattr(model, data["attribute"] + "Changed", MagicMock()) - - # Attempt to set the value - getattr(model, "set" + attribute)(data["value"]) - - # Check if signal fired. - signal = getattr(model, data["attribute"] + "Changed") - 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 - assert signal.emit.call_count == 1 - - -@pytest.mark.parametrize("data", test_validate_data_get_update) -def test_getAndUpdate(data): - model = PrintJobOutputModel(MagicMock()) - - # Convert the first letter into a capital - attribute = list(data["attribute"]) - attribute[0] = attribute[0].capitalize() - attribute = "".join(attribute) - - # mock the correct emit - setattr(model, data["attribute"] + "Changed", MagicMock()) - - # Attempt to set the value - getattr(model, "update" + attribute)(data["value"]) - - # Check if signal fired. - signal = getattr(model, data["attribute"] + "Changed") - 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, "update" + attribute)(data["value"]) - # The signal should not fire again - assert signal.emit.call_count == 1 diff --git a/tests/PrinterOutput/TestPrinterOutputModel.py b/tests/PrinterOutput/TestPrinterOutputModel.py index f42149d50f..c0c7171410 100644 --- a/tests/PrinterOutput/TestPrinterOutputModel.py +++ b/tests/PrinterOutput/TestPrinterOutputModel.py @@ -4,7 +4,7 @@ from unittest.mock import MagicMock import pytest -from cura.PrinterOutput.PrintJobOutputModel import PrintJobOutputModel +from cura.UI.PrintJobOutputModel import PrintJobOutputModel from cura.PrinterOutput.PrinterOutputModel import PrinterOutputModel test_validate_data_get_set = [ |