From 2b45262a850533849deee64e793b290c2802fab3 Mon Sep 17 00:00:00 2001 From: Aleksei S Date: Fri, 23 Nov 2018 17:01:05 +0100 Subject: [PATCH] Added test for definition container CURA-5977 --- .../src/UM3OutputDevicePlugin.py | 9 ++-- resources/definitions/fdmprinter.def.json | 4 +- resources/definitions/uni_print_3d.def.json | 5 -- .../definitions/vertex_delta_k8800.def.json | 18 ------- tests/Settings/TestDefinitionContainer.py | 47 +++++++++++++++++++ 5 files changed, 52 insertions(+), 31 deletions(-) create mode 100644 tests/Settings/TestDefinitionContainer.py diff --git a/plugins/UM3NetworkPrinting/src/UM3OutputDevicePlugin.py b/plugins/UM3NetworkPrinting/src/UM3OutputDevicePlugin.py index 9c070f2de2..daea696cd1 100644 --- a/plugins/UM3NetworkPrinting/src/UM3OutputDevicePlugin.py +++ b/plugins/UM3NetworkPrinting/src/UM3OutputDevicePlugin.py @@ -1,4 +1,4 @@ -# Copyright (c) 2017 Ultimaker B.V. +# Copyright (c) 2018 Ultimaker B.V. # Cura is released under the terms of the LGPLv3 or higher. from UM.OutputDevice.OutputDevicePlugin import OutputDevicePlugin @@ -325,13 +325,12 @@ class UM3OutputDevicePlugin(OutputDevicePlugin): ## Handler for zeroConf detection. # Return True or False indicating if the process succeeded. - # Note that this function can take over 3 seconds to complete. Be carefull calling it from the main thread. + # Note that this function can take over 3 seconds to complete. Be careful + # calling it from the main thread. def _onServiceChanged(self, zero_conf, service_type, name, state_change): if state_change == ServiceStateChange.Added: - Logger.log("d", "Bonjour service added: %s" % name) - # First try getting info from zero-conf cache - info = ServiceInfo(service_type, name, properties={}) + info = ServiceInfo(service_type, name, properties = {}) for record in zero_conf.cache.entries_with_name(name.lower()): info.update_record(zero_conf, time(), record) diff --git a/resources/definitions/fdmprinter.def.json b/resources/definitions/fdmprinter.def.json index c015ab8ccb..f9d0d81b75 100644 --- a/resources/definitions/fdmprinter.def.json +++ b/resources/definitions/fdmprinter.def.json @@ -4149,9 +4149,7 @@ "minimum_value": "0", "enabled": "support_enable", "limit_to_extruder": "support_infill_extruder_nr", - "settable_per_mesh": true, - "fabricate_enabled": true, - "intermediate_enabled": true + "settable_per_mesh": true }, "support_interface_enable": { diff --git a/resources/definitions/uni_print_3d.def.json b/resources/definitions/uni_print_3d.def.json index 1612c1bf80..427177176a 100644 --- a/resources/definitions/uni_print_3d.def.json +++ b/resources/definitions/uni_print_3d.def.json @@ -26,11 +26,6 @@ "machine_center_is_zero": { "default_value": true }, "machine_nozzle_heat_up_speed": { "default_value": 2.0 }, "machine_nozzle_cool_down_speed": { "default_value": 2.0 }, - "machine_head_shape_min_x": { "default_value": 75 }, - "machine_head_shape_min_y": { "default_value": 18 }, - "machine_head_shape_max_x": { "default_value": 18 }, - "machine_head_shape_max_y": { "default_value": 35 }, - "machine_nozzle_gantry_distance": { "default_value": 55 }, "machine_gcode_flavor": { "default_value": "RepRap (Marlin/Sprinter)" }, "machine_start_gcode": { diff --git a/resources/definitions/vertex_delta_k8800.def.json b/resources/definitions/vertex_delta_k8800.def.json index 7059c2e7f0..df24bd84fb 100644 --- a/resources/definitions/vertex_delta_k8800.def.json +++ b/resources/definitions/vertex_delta_k8800.def.json @@ -30,27 +30,9 @@ "machine_shape": { "default_value": "elliptic" }, - "machine_head_shape_min_x": { - "default_value": 0 - }, - "machine_head_shape_min_y": { - "default_value": 0 - }, - "machine_head_shape_max_x": { - "default_value": 0 - }, - "machine_head_shape_max_y": { - "default_value": 0 - }, "gantry_height": { "default_value": 0 }, - "machine_nozzle_offset_x_1": { - "default_value": 0 - }, - "machine_nozzle_offset_y_1": { - "default_value": 0 - }, "machine_gcode_flavor": { "default_value": "RepRap (Marlin/Sprinter)" }, diff --git a/tests/Settings/TestDefinitionContainer.py b/tests/Settings/TestDefinitionContainer.py new file mode 100644 index 0000000000..147068fb8c --- /dev/null +++ b/tests/Settings/TestDefinitionContainer.py @@ -0,0 +1,47 @@ +# Copyright (c) 2018 Ultimaker B.V. +# Cura is released under the terms of the LGPLv3 or higher. + +import pytest #This module contains automated tests. + +import UM.Settings.ContainerRegistry #To create empty instance containers. +import UM.Settings.ContainerStack #To set the container registry the container stacks use. +from UM.Settings.DefinitionContainer import DefinitionContainer #To check against the class of DefinitionContainer. + + + +import os +import os.path +import uuid + +from UM.Resources import Resources +Resources.addSearchPath(os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..", "resources"))) + + +#############################START OF TEST CASES################################ + +@pytest.fixture +def definition_container(): + uid = str(uuid.uuid4()) + result = UM.Settings.DefinitionContainer.DefinitionContainer(uid) + assert result.getId() == uid + return result + +## Tests all definition containers +def test_validateDefintionContainer(definition_container): + + definition_path = os.path.join(os.path.dirname(__file__), "..", "..", "resources", "definitions") + all_definition_files = os.listdir(definition_path) + + for file_name in all_definition_files: + + if file_name == "fdmprinter.def.json" or file_name == "fdmextruder.def.json": + continue + + with open(os.path.join(definition_path, file_name), encoding = "utf-8") as data: + + json = data.read() + parser, is_valid = definition_container.readAndValidateSerialized(json) + if(not is_valid): + print("The File Name: '{0}', has invalid data ".format(file_name)) + # To see the detailed data from log, comment the assert check and execute the test again. It will print invalid data + assert is_valid == True \ No newline at end of file