Remove old deserialize tests

Most of these tests also tested the Uranium code, which it should mock out. The last test, test_deserializeMissingContainer, is caught by the currently existing tests.

Contributes to issue CURA-3497.
This commit is contained in:
Ghostkeeper 2017-04-10 17:14:50 +02:00
parent f12ffad2c1
commit 71aca6aa4b
No known key found for this signature in database
GPG Key ID: C5F96EE2BC0F7E75

View File

@ -356,195 +356,6 @@ def test_deserializeMoveDefinitionContainer(global_stack):
assert global_stack.material.getId() == "empty"
assert global_stack.definition.getId() != "empty"
## Tests whether the user changes are being read properly from a global stack.
@pytest.mark.skip
@pytest.mark.parametrize("filename, user_changes_id", [
("Global.global.cfg", "empty"),
("Global.stack.cfg", "empty"),
("MachineLegacy.stack.cfg", "empty"),
("OnlyUser.global.cfg", "some_instance"), #This one does have a user profile.
("Complete.global.cfg", "some_user_changes")
])
def test_deserializeUserChanges(filename, user_changes_id, container_registry, global_stack):
serialized = readStack(filename)
#Mock the loading of the instance containers.
global_stack.findContainer = findSomeContainers
original_container_registry = UM.Settings.ContainerStack._containerRegistry
UM.Settings.ContainerStack._containerRegistry = container_registry #Always has all profiles you ask of.
global_stack.deserialize(serialized)
assert global_stack.userChanges.getId() == user_changes_id
#Restore.
UM.Settings.ContainerStack._containerRegistry = original_container_registry
## Tests whether the quality changes are being read properly from a global
# stack.
@pytest.mark.skip
@pytest.mark.parametrize("filename, quality_changes_id", [
("Global.global.cfg", "empty"),
("Global.stack.cfg", "empty"),
("MachineLegacy.stack.cfg", "empty"),
("OnlyQualityChanges.global.cfg", "some_instance"),
("Complete.global.cfg", "some_quality_changes")
])
def test_deserializeQualityChanges(filename, quality_changes_id, container_registry, global_stack):
serialized = readStack(filename)
#Mock the loading of the instance containers.
global_stack.findContainer = findSomeContainers
original_container_registry = UM.Settings.ContainerStack._containerRegistry
UM.Settings.ContainerStack._containerRegistry = container_registry #Always has all the profiles you ask of.
global_stack.deserialize(serialized)
assert global_stack.qualityChanges.getId() == quality_changes_id
#Restore.
UM.Settings.ContainerStack._containerRegistry = original_container_registry
## Tests whether the quality profile is being read properly from a global
# stack.
@pytest.mark.skip
@pytest.mark.parametrize("filename, quality_id", [
("Global.global.cfg", "empty"),
("Global.stack.cfg", "empty"),
("MachineLegacy.stack.cfg", "empty"),
("OnlyQuality.global.cfg", "some_instance"),
("Complete.global.cfg", "some_quality")
])
def test_deserializeQuality(filename, quality_id, container_registry, global_stack):
serialized = readStack(filename)
#Mock the loading of the instance containers.
global_stack.findContainer = findSomeContainers
original_container_registry = UM.Settings.ContainerStack._containerRegistry
UM.Settings.ContainerStack._containerRegistry = container_registry #Always has all the profiles you ask of.
global_stack.deserialize(serialized)
assert global_stack.quality.getId() == quality_id
#Restore.
UM.Settings.ContainerStack._containerRegistry = original_container_registry
## Tests whether the material profile is being read properly from a global
# stack.
@pytest.mark.skip
@pytest.mark.parametrize("filename, material_id", [
("Global.global.cfg", "some_instance"),
("Global.stack.cfg", "some_instance"),
("MachineLegacy.stack.cfg", "some_instance"),
("OnlyDefinition.global.cfg", "empty"),
("OnlyMaterial.global.cfg", "some_instance"),
("Complete.global.cfg", "some_material")
])
def test_deserializeMaterial(filename, material_id, container_registry, global_stack):
serialized = readStack(filename)
#Mock the loading of the instance containers.
global_stack.findContainer = findSomeContainers
original_container_registry = UM.Settings.ContainerStack._containerRegistry
UM.Settings.ContainerStack._containerRegistry = container_registry #Always has all the profiles you ask of.
global_stack.deserialize(serialized)
assert global_stack.material.getId() == material_id
#Restore.
UM.Settings.ContainerStack._containerRegistry = original_container_registry
## Tests whether the variant profile is being read properly from a global
# stack.
@pytest.mark.skip
@pytest.mark.parametrize("filename, variant_id", [
("Global.global.cfg", "empty"),
("Global.stack.cfg", "empty"),
("MachineLegacy.stack.cfg", "empty"),
("OnlyVariant.global.cfg", "some_instance"),
("Complete.global.cfg", "some_variant")
])
def test_deserializeVariant(filename, variant_id, container_registry, global_stack):
serialized = readStack(filename)
#Mock the loading of the instance containers.
global_stack.findContainer = findSomeContainers
original_container_registry = UM.Settings.ContainerStack._containerRegistry
UM.Settings.ContainerStack._containerRegistry = container_registry #Always has all the profiles you ask of.
global_stack.deserialize(serialized)
assert global_stack.variant.getId() == variant_id
#Restore.
UM.Settings.ContainerStack._containerRegistry = original_container_registry
## Tests whether the definition changes profile is being read properly from a
# global stack.
@pytest.mark.skip
@pytest.mark.parametrize("filename, definition_changes_id", [
("Global.global.cfg", "empty"),
("Global.stack.cfg", "empty"),
("MachineLegacy.stack.cfg", "empty"),
("OnlyDefinitionChanges.global.cfg", "some_instance"),
("Complete.global.cfg", "some_material")
])
def test_deserializeDefinitionChanges(filename, definition_changes_id, container_registry, global_stack):
serialized = readStack(filename)
global_stack = cura.Settings.GlobalStack.GlobalStack("TestStack")
#Mock the loading of the instance containers.
global_stack.findContainer = findSomeContainers
original_container_registry = UM.Settings.ContainerStack._containerRegistry
UM.Settings.ContainerStack._containerRegistry = container_registry #Always has all the profiles you ask of.
global_stack.deserialize(serialized)
assert global_stack.definitionChanges.getId() == definition_changes_id
#Restore.
UM.Settings.ContainerStack._containerRegistry = original_container_registry
## Tests whether the definition is being read properly from a global stack.
@pytest.mark.skip
@pytest.mark.parametrize("filename, definition_id", [
("Global.global.cfg", "some_definition"),
("Global.stack.cfg", "some_definition"),
("MachineLegacy.stack.cfg", "some_definition"),
("OnlyDefinition.global.cfg", "some_definition"),
("Complete.global.cfg", "some_definition")
])
def test_deserializeDefinition(filename, definition_id, container_registry, global_stack):
serialized = readStack(filename)
#Mock the loading of the instance containers.
global_stack.findContainer = findSomeContainers
original_container_registry = UM.Settings.ContainerStack._containerRegistry
UM.Settings.ContainerStack._containerRegistry = container_registry #Always has all the profiles you ask of.
global_stack.deserialize(serialized)
assert global_stack.definition.getId() == definition_id
#Restore.
UM.Settings.ContainerStack._containerRegistry = original_container_registry
## Tests that when a global stack is loaded with an unknown instance, it raises
# an exception.
@pytest.mark.skip
def test_deserializeMissingContainer(global_stack):
serialized = readStack("Global.global.cfg")
with pytest.raises(Exception):
global_stack.deserialize(serialized)
try:
global_stack.deserialize(serialized)
except Exception as e:
#Must be exactly Exception, not one of its subclasses, since that is what gets raised when a stack has an unknown container.
#That's why we can't use pytest.raises.
assert type(e) == Exception
## Tests whether getProperty properly applies the stack-like behaviour on its
# containers.
def test_getPropertyFallThrough(global_stack):