diff options
author | Lipu Fei <lipu.fei815@gmail.com> | 2019-03-20 11:42:22 +0300 |
---|---|---|
committer | Lipu Fei <lipu.fei815@gmail.com> | 2019-03-20 11:43:10 +0300 |
commit | 6a8db55112f136f6ea3fbc4e987987c4c267b9db (patch) | |
tree | 5abaf9ebe1bf7f0f58231928c42cc413193697bc /tests/PrinterOutput | |
parent | 2b39d6422c63d0863c1ae4115197b25468f8e321 (diff) |
Move PrinterOutputModel into cura.UI module
Diffstat (limited to 'tests/PrinterOutput')
-rw-r--r-- | tests/PrinterOutput/TestPrinterOutputModel.py | 81 |
1 files changed, 0 insertions, 81 deletions
diff --git a/tests/PrinterOutput/TestPrinterOutputModel.py b/tests/PrinterOutput/TestPrinterOutputModel.py deleted file mode 100644 index c0c7171410..0000000000 --- a/tests/PrinterOutput/TestPrinterOutputModel.py +++ /dev/null @@ -1,81 +0,0 @@ - - -from unittest.mock import MagicMock - -import pytest - -from cura.UI.PrintJobOutputModel import PrintJobOutputModel -from cura.PrinterOutput.PrinterOutputModel import PrinterOutputModel - -test_validate_data_get_set = [ - {"attribute": "name", "value": "YAY"}, - {"attribute": "targetBedTemperature", "value": 192}, -] - -test_validate_data_get_update = [ - {"attribute": "isPreheating", "value": True}, - {"attribute": "type", "value": "WHOO"}, - {"attribute": "buildplate", "value": "NFHA"}, - {"attribute": "key", "value": "YAY"}, - {"attribute": "name", "value": "Turtles"}, - {"attribute": "bedTemperature", "value": 200}, - {"attribute": "targetBedTemperature", "value": 9001}, - {"attribute": "activePrintJob", "value": PrintJobOutputModel(MagicMock())}, - {"attribute": "state", "value": "BEEPBOOP"}, -] - - -@pytest.mark.parametrize("data", test_validate_data_get_set) -def test_getAndSet(data): - model = PrinterOutputModel(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 = PrinterOutputModel(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 |