mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-11-02 20:52:20 -07:00
WIP: Remove set..ById()s in CuraContainerStack
This commit is contained in:
parent
4af176dbf3
commit
12164a0c88
4 changed files with 6 additions and 250 deletions
|
|
@ -579,21 +579,21 @@ class CuraContainerRegistry(ContainerRegistry):
|
||||||
variant_id = machine.variant.getId()
|
variant_id = machine.variant.getId()
|
||||||
else:
|
else:
|
||||||
variant_id = "empty_variant"
|
variant_id = "empty_variant"
|
||||||
extruder_stack.setVariantById(variant_id)
|
extruder_stack.variant = self.findInstanceContainers(id = variant_id)[0]
|
||||||
|
|
||||||
material_id = "default"
|
material_id = "default"
|
||||||
if machine.material.getId() not in ("empty", "empty_material"):
|
if machine.material.getId() not in ("empty", "empty_material"):
|
||||||
material_id = machine.material.getId()
|
material_id = machine.material.getId()
|
||||||
else:
|
else:
|
||||||
material_id = "empty_material"
|
material_id = "empty_material"
|
||||||
extruder_stack.setMaterialById(material_id)
|
extruder_stack.material = self.findInstanceContainers(id = material_id)[0]
|
||||||
|
|
||||||
quality_id = "default"
|
quality_id = "default"
|
||||||
if machine.quality.getId() not in ("empty", "empty_quality"):
|
if machine.quality.getId() not in ("empty", "empty_quality"):
|
||||||
quality_id = machine.quality.getId()
|
quality_id = machine.quality.getId()
|
||||||
else:
|
else:
|
||||||
quality_id = "empty_quality"
|
quality_id = "empty_quality"
|
||||||
extruder_stack.setQualityById(quality_id)
|
extruder_stack.quality = self.findInstanceContainers(id = quality_id)[0]
|
||||||
|
|
||||||
machine_quality_changes = machine.qualityChanges
|
machine_quality_changes = machine.qualityChanges
|
||||||
if new_global_quality_changes is not None:
|
if new_global_quality_changes is not None:
|
||||||
|
|
@ -605,7 +605,7 @@ class CuraContainerRegistry(ContainerRegistry):
|
||||||
extruder_quality_changes_container = extruder_quality_changes_container[0]
|
extruder_quality_changes_container = extruder_quality_changes_container[0]
|
||||||
|
|
||||||
quality_changes_id = extruder_quality_changes_container.getId()
|
quality_changes_id = extruder_quality_changes_container.getId()
|
||||||
extruder_stack.setQualityChangesById(quality_changes_id)
|
extruder_stack.qualityChanges = self.findInstanceContainers(id = quality_changes_id)[0]
|
||||||
else:
|
else:
|
||||||
# Some extruder quality_changes containers can be created at runtime as files in the qualities
|
# Some extruder quality_changes containers can be created at runtime as files in the qualities
|
||||||
# folder. Those files won't be loaded in the registry immediately. So we also need to search
|
# folder. Those files won't be loaded in the registry immediately. So we also need to search
|
||||||
|
|
@ -614,7 +614,7 @@ class CuraContainerRegistry(ContainerRegistry):
|
||||||
if extruder_quality_changes_container:
|
if extruder_quality_changes_container:
|
||||||
quality_changes_id = extruder_quality_changes_container.getId()
|
quality_changes_id = extruder_quality_changes_container.getId()
|
||||||
extruder_quality_changes_container.addMetaDataEntry("extruder", extruder_stack.definition.getId())
|
extruder_quality_changes_container.addMetaDataEntry("extruder", extruder_stack.definition.getId())
|
||||||
extruder_stack.setQualityChangesById(quality_changes_id)
|
extruder_stack.qualityChanges = self.findInstanceContainers(id = quality_changes_id)[0]
|
||||||
else:
|
else:
|
||||||
# if we still cannot find a quality changes container for the extruder, create a new one
|
# if we still cannot find a quality changes container for the extruder, create a new one
|
||||||
container_name = machine_quality_changes.getName()
|
container_name = machine_quality_changes.getName()
|
||||||
|
|
@ -649,7 +649,7 @@ class CuraContainerRegistry(ContainerRegistry):
|
||||||
|
|
||||||
machine_quality_changes.removeInstance(qc_setting_key, postpone_emit=True)
|
machine_quality_changes.removeInstance(qc_setting_key, postpone_emit=True)
|
||||||
else:
|
else:
|
||||||
extruder_stack.setQualityChangesById("empty_quality_changes")
|
extruder_stack.qualityChanges = self.findInstanceContainers(id = "empty_quality_changes")[0]
|
||||||
|
|
||||||
self.addContainer(extruder_stack)
|
self.addContainer(extruder_stack)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -83,20 +83,6 @@ class CuraContainerStack(ContainerStack):
|
||||||
def setQualityChanges(self, new_quality_changes: InstanceContainer, postpone_emit = False) -> None:
|
def setQualityChanges(self, new_quality_changes: InstanceContainer, postpone_emit = False) -> None:
|
||||||
self.replaceContainer(_ContainerIndexes.QualityChanges, new_quality_changes, postpone_emit = postpone_emit)
|
self.replaceContainer(_ContainerIndexes.QualityChanges, new_quality_changes, postpone_emit = postpone_emit)
|
||||||
|
|
||||||
## Set the quality changes container by an ID.
|
|
||||||
#
|
|
||||||
# This will search for the specified container and set it. If no container was found, an error will be raised.
|
|
||||||
#
|
|
||||||
# \param new_quality_changes_id The ID of the new quality changes container.
|
|
||||||
#
|
|
||||||
# \throws Exceptions.InvalidContainerError Raised when no container could be found with the specified ID.
|
|
||||||
def setQualityChangesById(self, new_quality_changes_id: str) -> None:
|
|
||||||
quality_changes = ContainerRegistry.getInstance().findInstanceContainers(id = new_quality_changes_id)
|
|
||||||
if quality_changes:
|
|
||||||
self.setQualityChanges(quality_changes[0])
|
|
||||||
else:
|
|
||||||
raise Exceptions.InvalidContainerError("Could not find container with id {id}".format(id = new_quality_changes_id))
|
|
||||||
|
|
||||||
## Get the quality changes container.
|
## Get the quality changes container.
|
||||||
#
|
#
|
||||||
# \return The quality changes container. Should always be a valid container, but can be equal to the empty InstanceContainer.
|
# \return The quality changes container. Should always be a valid container, but can be equal to the empty InstanceContainer.
|
||||||
|
|
@ -110,31 +96,6 @@ class CuraContainerStack(ContainerStack):
|
||||||
def setQuality(self, new_quality: InstanceContainer, postpone_emit = False) -> None:
|
def setQuality(self, new_quality: InstanceContainer, postpone_emit = False) -> None:
|
||||||
self.replaceContainer(_ContainerIndexes.Quality, new_quality, postpone_emit = postpone_emit)
|
self.replaceContainer(_ContainerIndexes.Quality, new_quality, postpone_emit = postpone_emit)
|
||||||
|
|
||||||
## Set the quality container by an ID.
|
|
||||||
#
|
|
||||||
# This will search for the specified container and set it. If no container was found, an error will be raised.
|
|
||||||
# There is a special value for ID, which is "default". The "default" value indicates the quality should be set
|
|
||||||
# to whatever the machine definition specifies as "preferred" container, or a fallback value. See findDefaultQuality
|
|
||||||
# for details.
|
|
||||||
#
|
|
||||||
# \param new_quality_id The ID of the new quality container.
|
|
||||||
#
|
|
||||||
# \throws Exceptions.InvalidContainerError Raised when no container could be found with the specified ID.
|
|
||||||
def setQualityById(self, new_quality_id: str) -> None:
|
|
||||||
quality = self._empty_quality
|
|
||||||
if new_quality_id == "default":
|
|
||||||
new_quality = self.findDefaultQuality()
|
|
||||||
if new_quality:
|
|
||||||
quality = new_quality
|
|
||||||
else:
|
|
||||||
qualities = ContainerRegistry.getInstance().findInstanceContainers(id = new_quality_id)
|
|
||||||
if qualities:
|
|
||||||
quality = qualities[0]
|
|
||||||
else:
|
|
||||||
raise Exceptions.InvalidContainerError("Could not find container with id {id}".format(id = new_quality_id))
|
|
||||||
|
|
||||||
self.setQuality(quality)
|
|
||||||
|
|
||||||
## Get the quality container.
|
## Get the quality container.
|
||||||
#
|
#
|
||||||
# \return The quality container. Should always be a valid container, but can be equal to the empty InstanceContainer.
|
# \return The quality container. Should always be a valid container, but can be equal to the empty InstanceContainer.
|
||||||
|
|
@ -148,31 +109,6 @@ class CuraContainerStack(ContainerStack):
|
||||||
def setMaterial(self, new_material: InstanceContainer, postpone_emit = False) -> None:
|
def setMaterial(self, new_material: InstanceContainer, postpone_emit = False) -> None:
|
||||||
self.replaceContainer(_ContainerIndexes.Material, new_material, postpone_emit = postpone_emit)
|
self.replaceContainer(_ContainerIndexes.Material, new_material, postpone_emit = postpone_emit)
|
||||||
|
|
||||||
## Set the material container by an ID.
|
|
||||||
#
|
|
||||||
# This will search for the specified container and set it. If no container was found, an error will be raised.
|
|
||||||
# There is a special value for ID, which is "default". The "default" value indicates the quality should be set
|
|
||||||
# to whatever the machine definition specifies as "preferred" container, or a fallback value. See findDefaultMaterial
|
|
||||||
# for details.
|
|
||||||
#
|
|
||||||
# \param new_material_id The ID of the new material container.
|
|
||||||
#
|
|
||||||
# \throws Exceptions.InvalidContainerError Raised when no container could be found with the specified ID.
|
|
||||||
def setMaterialById(self, new_material_id: str) -> None:
|
|
||||||
material = self._empty_material
|
|
||||||
if new_material_id == "default":
|
|
||||||
new_material = self.findDefaultMaterial()
|
|
||||||
if new_material:
|
|
||||||
material = new_material
|
|
||||||
else:
|
|
||||||
materials = ContainerRegistry.getInstance().findInstanceContainers(id = new_material_id)
|
|
||||||
if materials:
|
|
||||||
material = materials[0]
|
|
||||||
else:
|
|
||||||
raise Exceptions.InvalidContainerError("Could not find container with id {id}".format(id = new_material_id))
|
|
||||||
|
|
||||||
self.setMaterial(material)
|
|
||||||
|
|
||||||
## Get the material container.
|
## Get the material container.
|
||||||
#
|
#
|
||||||
# \return The material container. Should always be a valid container, but can be equal to the empty InstanceContainer.
|
# \return The material container. Should always be a valid container, but can be equal to the empty InstanceContainer.
|
||||||
|
|
@ -186,31 +122,6 @@ class CuraContainerStack(ContainerStack):
|
||||||
def setVariant(self, new_variant: InstanceContainer) -> None:
|
def setVariant(self, new_variant: InstanceContainer) -> None:
|
||||||
self.replaceContainer(_ContainerIndexes.Variant, new_variant)
|
self.replaceContainer(_ContainerIndexes.Variant, new_variant)
|
||||||
|
|
||||||
## Set the variant container by an ID.
|
|
||||||
#
|
|
||||||
# This will search for the specified container and set it. If no container was found, an error will be raised.
|
|
||||||
# There is a special value for ID, which is "default". The "default" value indicates the quality should be set
|
|
||||||
# to whatever the machine definition specifies as "preferred" container, or a fallback value. See findDefaultVariant
|
|
||||||
# for details.
|
|
||||||
#
|
|
||||||
# \param new_variant_id The ID of the new variant container.
|
|
||||||
#
|
|
||||||
# \throws Exceptions.InvalidContainerError Raised when no container could be found with the specified ID.
|
|
||||||
def setVariantById(self, new_variant_id: str) -> None:
|
|
||||||
variant = self._empty_variant
|
|
||||||
if new_variant_id == "default":
|
|
||||||
new_variant = self.findDefaultVariantBuildplate() if self.getMetaDataEntry("type") == "machine" else self.findDefaultVariant()
|
|
||||||
if new_variant:
|
|
||||||
variant = new_variant
|
|
||||||
else:
|
|
||||||
variants = ContainerRegistry.getInstance().findInstanceContainers(id = new_variant_id)
|
|
||||||
if variants:
|
|
||||||
variant = variants[0]
|
|
||||||
else:
|
|
||||||
raise Exceptions.InvalidContainerError("Could not find container with id {id}".format(id = new_variant_id))
|
|
||||||
|
|
||||||
self.setVariant(variant)
|
|
||||||
|
|
||||||
## Get the variant container.
|
## Get the variant container.
|
||||||
#
|
#
|
||||||
# \return The variant container. Should always be a valid container, but can be equal to the empty InstanceContainer.
|
# \return The variant container. Should always be a valid container, but can be equal to the empty InstanceContainer.
|
||||||
|
|
@ -224,18 +135,6 @@ class CuraContainerStack(ContainerStack):
|
||||||
def setDefinitionChanges(self, new_definition_changes: InstanceContainer) -> None:
|
def setDefinitionChanges(self, new_definition_changes: InstanceContainer) -> None:
|
||||||
self.replaceContainer(_ContainerIndexes.DefinitionChanges, new_definition_changes)
|
self.replaceContainer(_ContainerIndexes.DefinitionChanges, new_definition_changes)
|
||||||
|
|
||||||
## Set the definition changes container by an ID.
|
|
||||||
#
|
|
||||||
# \param new_definition_changes_id The ID of the new definition changes container.
|
|
||||||
#
|
|
||||||
# \throws Exceptions.InvalidContainerError Raised when no container could be found with the specified ID.
|
|
||||||
def setDefinitionChangesById(self, new_definition_changes_id: str) -> None:
|
|
||||||
new_definition_changes = ContainerRegistry.getInstance().findInstanceContainers(id = new_definition_changes_id)
|
|
||||||
if new_definition_changes:
|
|
||||||
self.setDefinitionChanges(new_definition_changes[0])
|
|
||||||
else:
|
|
||||||
raise Exceptions.InvalidContainerError("Could not find container with id {id}".format(id = new_definition_changes_id))
|
|
||||||
|
|
||||||
## Get the definition changes container.
|
## Get the definition changes container.
|
||||||
#
|
#
|
||||||
# \return The definition changes container. Should always be a valid container, but can be equal to the empty InstanceContainer.
|
# \return The definition changes container. Should always be a valid container, but can be equal to the empty InstanceContainer.
|
||||||
|
|
@ -249,18 +148,6 @@ class CuraContainerStack(ContainerStack):
|
||||||
def setDefinition(self, new_definition: DefinitionContainerInterface) -> None:
|
def setDefinition(self, new_definition: DefinitionContainerInterface) -> None:
|
||||||
self.replaceContainer(_ContainerIndexes.Definition, new_definition)
|
self.replaceContainer(_ContainerIndexes.Definition, new_definition)
|
||||||
|
|
||||||
## Set the definition container by an ID.
|
|
||||||
#
|
|
||||||
# \param new_definition_id The ID of the new definition container.
|
|
||||||
#
|
|
||||||
# \throws Exceptions.InvalidContainerError Raised when no container could be found with the specified ID.
|
|
||||||
def setDefinitionById(self, new_definition_id: str) -> None:
|
|
||||||
new_definition = ContainerRegistry.getInstance().findDefinitionContainers(id = new_definition_id)
|
|
||||||
if new_definition:
|
|
||||||
self.setDefinition(new_definition[0])
|
|
||||||
else:
|
|
||||||
raise Exceptions.InvalidContainerError("Could not find container with id {id}".format(id = new_definition_id))
|
|
||||||
|
|
||||||
## Get the definition container.
|
## Get the definition container.
|
||||||
#
|
#
|
||||||
# \return The definition container. Should always be a valid container, but can be equal to the empty InstanceContainer.
|
# \return The definition container. Should always be a valid container, but can be equal to the empty InstanceContainer.
|
||||||
|
|
|
||||||
|
|
@ -325,30 +325,6 @@ def test_removeContainer(extruder_stack):
|
||||||
with pytest.raises(InvalidOperationError):
|
with pytest.raises(InvalidOperationError):
|
||||||
extruder_stack.removeContainer(unittest.mock.MagicMock())
|
extruder_stack.removeContainer(unittest.mock.MagicMock())
|
||||||
|
|
||||||
## Tests setting definitions by specifying an ID of a definition that exists.
|
|
||||||
def test_setDefinitionByIdExists(extruder_stack, container_registry):
|
|
||||||
container_registry.return_value = DefinitionContainer(container_id = "some_definition")
|
|
||||||
extruder_stack.setDefinitionById("some_definition")
|
|
||||||
assert extruder_stack.definition.getId() == "some_definition"
|
|
||||||
|
|
||||||
## Tests setting definitions by specifying an ID of a definition that doesn't
|
|
||||||
# exist.
|
|
||||||
def test_setDefinitionByIdDoesntExist(extruder_stack):
|
|
||||||
with pytest.raises(InvalidContainerError):
|
|
||||||
extruder_stack.setDefinitionById("some_definition") #Container registry is empty now.
|
|
||||||
|
|
||||||
## Tests setting materials by specifying an ID of a material that exists.
|
|
||||||
def test_setMaterialByIdExists(extruder_stack, container_registry):
|
|
||||||
container_registry.return_value = getInstanceContainer(container_type = "material")
|
|
||||||
extruder_stack.setMaterialById("InstanceContainer")
|
|
||||||
assert extruder_stack.material.getId() == "InstanceContainer"
|
|
||||||
|
|
||||||
## Tests setting materials by specifying an ID of a material that doesn't
|
|
||||||
# exist.
|
|
||||||
def test_setMaterialByIdDoesntExist(extruder_stack):
|
|
||||||
with pytest.raises(InvalidContainerError):
|
|
||||||
extruder_stack.setMaterialById("some_material") #Container registry is empty now.
|
|
||||||
|
|
||||||
## Tests setting properties directly on the extruder stack.
|
## Tests setting properties directly on the extruder stack.
|
||||||
@pytest.mark.parametrize("key, property, value", [
|
@pytest.mark.parametrize("key, property, value", [
|
||||||
("layer_height", "value", 0.1337),
|
("layer_height", "value", 0.1337),
|
||||||
|
|
@ -387,38 +363,3 @@ def test_setPropertyOtherContainers(target_container, stack_variable, extruder_s
|
||||||
extruder_stack.setProperty(key, property, value, target_container = target_container) #The actual test.
|
extruder_stack.setProperty(key, property, value, target_container = target_container) #The actual test.
|
||||||
|
|
||||||
getattr(extruder_stack, stack_variable).setProperty.assert_called_once_with(key, property, value) #Make sure that the proper container gets a setProperty call.
|
getattr(extruder_stack, stack_variable).setProperty.assert_called_once_with(key, property, value) #Make sure that the proper container gets a setProperty call.
|
||||||
|
|
||||||
## Tests setting qualities by specifying an ID of a quality that exists.
|
|
||||||
def test_setQualityByIdExists(extruder_stack, container_registry):
|
|
||||||
container_registry.return_value = getInstanceContainer(container_type = "quality")
|
|
||||||
extruder_stack.setQualityById("InstanceContainer")
|
|
||||||
assert extruder_stack.quality.getId() == "InstanceContainer"
|
|
||||||
|
|
||||||
## Tests setting qualities by specifying an ID of a quality that doesn't exist.
|
|
||||||
def test_setQualityByIdDoesntExist(extruder_stack):
|
|
||||||
with pytest.raises(InvalidContainerError):
|
|
||||||
extruder_stack.setQualityById("some_quality") #Container registry is empty now.
|
|
||||||
|
|
||||||
## Tests setting quality changes by specifying an ID of a quality change that
|
|
||||||
# exists.
|
|
||||||
def test_setQualityChangesByIdExists(extruder_stack, container_registry):
|
|
||||||
container_registry.return_value = getInstanceContainer(container_type = "quality_changes")
|
|
||||||
extruder_stack.setQualityChangesById("InstanceContainer")
|
|
||||||
assert extruder_stack.qualityChanges.getId() == "InstanceContainer"
|
|
||||||
|
|
||||||
## Tests setting quality changes by specifying an ID of a quality change that
|
|
||||||
# doesn't exist.
|
|
||||||
def test_setQualityChangesByIdDoesntExist(extruder_stack):
|
|
||||||
with pytest.raises(InvalidContainerError):
|
|
||||||
extruder_stack.setQualityChangesById("some_quality_changes") #Container registry is empty now.
|
|
||||||
|
|
||||||
## Tests setting variants by specifying an ID of a variant that exists.
|
|
||||||
def test_setVariantByIdExists(extruder_stack, container_registry):
|
|
||||||
container_registry.return_value = getInstanceContainer(container_type = "variant")
|
|
||||||
extruder_stack.setVariantById("InstanceContainer")
|
|
||||||
assert extruder_stack.variant.getId() == "InstanceContainer"
|
|
||||||
|
|
||||||
## Tests setting variants by specifying an ID of a variant that doesn't exist.
|
|
||||||
def test_setVariantByIdDoesntExist(extruder_stack):
|
|
||||||
with pytest.raises(InvalidContainerError):
|
|
||||||
extruder_stack.setVariantById("some_variant") #Container registry is empty now.
|
|
||||||
|
|
|
||||||
|
|
@ -486,43 +486,6 @@ def test_removeContainer(global_stack):
|
||||||
with pytest.raises(InvalidOperationError):
|
with pytest.raises(InvalidOperationError):
|
||||||
global_stack.removeContainer(unittest.mock.MagicMock())
|
global_stack.removeContainer(unittest.mock.MagicMock())
|
||||||
|
|
||||||
## Tests setting definitions by specifying an ID of a definition that exists.
|
|
||||||
def test_setDefinitionByIdExists(global_stack, container_registry):
|
|
||||||
container_registry.return_value = DefinitionContainer(container_id = "some_definition")
|
|
||||||
global_stack.setDefinitionById("some_definition")
|
|
||||||
assert global_stack.definition.getId() == "some_definition"
|
|
||||||
|
|
||||||
## Tests setting definitions by specifying an ID of a definition that doesn't
|
|
||||||
# exist.
|
|
||||||
def test_setDefinitionByIdDoesntExist(global_stack):
|
|
||||||
with pytest.raises(InvalidContainerError):
|
|
||||||
global_stack.setDefinitionById("some_definition") #Container registry is empty now.
|
|
||||||
|
|
||||||
## Tests setting definition changes by specifying an ID of a container that
|
|
||||||
# exists.
|
|
||||||
def test_setDefinitionChangesByIdExists(global_stack, container_registry):
|
|
||||||
container_registry.return_value = getInstanceContainer(container_type = "definition_changes")
|
|
||||||
global_stack.setDefinitionChangesById("InstanceContainer")
|
|
||||||
assert global_stack.definitionChanges.getId() == "InstanceContainer"
|
|
||||||
|
|
||||||
## Tests setting definition changes by specifying an ID of a container that
|
|
||||||
# doesn't exist.
|
|
||||||
def test_setDefinitionChangesByIdDoesntExist(global_stack):
|
|
||||||
with pytest.raises(InvalidContainerError):
|
|
||||||
global_stack.setDefinitionChangesById("some_definition_changes") #Container registry is empty now.
|
|
||||||
|
|
||||||
## Tests setting materials by specifying an ID of a material that exists.
|
|
||||||
def test_setMaterialByIdExists(global_stack, container_registry):
|
|
||||||
container_registry.return_value = getInstanceContainer(container_type = "material")
|
|
||||||
global_stack.setMaterialById("InstanceContainer")
|
|
||||||
assert global_stack.material.getId() == "InstanceContainer"
|
|
||||||
|
|
||||||
## Tests setting materials by specifying an ID of a material that doesn't
|
|
||||||
# exist.
|
|
||||||
def test_setMaterialByIdDoesntExist(global_stack):
|
|
||||||
with pytest.raises(InvalidContainerError):
|
|
||||||
global_stack.setMaterialById("some_material") #Container registry is empty now.
|
|
||||||
|
|
||||||
## Tests whether changing the next stack is properly forbidden.
|
## Tests whether changing the next stack is properly forbidden.
|
||||||
def test_setNextStack(global_stack):
|
def test_setNextStack(global_stack):
|
||||||
with pytest.raises(InvalidOperationError):
|
with pytest.raises(InvalidOperationError):
|
||||||
|
|
@ -568,41 +531,6 @@ def test_setPropertyOtherContainers(target_container, stack_variable, global_sta
|
||||||
|
|
||||||
getattr(global_stack, stack_variable).setProperty.assert_called_once_with(key, property, value) #Make sure that the proper container gets a setProperty call.
|
getattr(global_stack, stack_variable).setProperty.assert_called_once_with(key, property, value) #Make sure that the proper container gets a setProperty call.
|
||||||
|
|
||||||
## Tests setting qualities by specifying an ID of a quality that exists.
|
|
||||||
def test_setQualityByIdExists(global_stack, container_registry):
|
|
||||||
container_registry.return_value = getInstanceContainer(container_type = "quality")
|
|
||||||
global_stack.setQualityById("InstanceContainer")
|
|
||||||
assert global_stack.quality.getId() == "InstanceContainer"
|
|
||||||
|
|
||||||
## Tests setting qualities by specifying an ID of a quality that doesn't exist.
|
|
||||||
def test_setQualityByIdDoesntExist(global_stack):
|
|
||||||
with pytest.raises(InvalidContainerError):
|
|
||||||
global_stack.setQualityById("some_quality") #Container registry is empty now.
|
|
||||||
|
|
||||||
## Tests setting quality changes by specifying an ID of a quality change that
|
|
||||||
# exists.
|
|
||||||
def test_setQualityChangesByIdExists(global_stack, container_registry):
|
|
||||||
container_registry.return_value = getInstanceContainer(container_type = "quality_changes")
|
|
||||||
global_stack.setQualityChangesById("InstanceContainer")
|
|
||||||
assert global_stack.qualityChanges.getId() == "InstanceContainer"
|
|
||||||
|
|
||||||
## Tests setting quality changes by specifying an ID of a quality change that
|
|
||||||
# doesn't exist.
|
|
||||||
def test_setQualityChangesByIdDoesntExist(global_stack):
|
|
||||||
with pytest.raises(InvalidContainerError):
|
|
||||||
global_stack.setQualityChangesById("some_quality_changes") #Container registry is empty now.
|
|
||||||
|
|
||||||
## Tests setting variants by specifying an ID of a variant that exists.
|
|
||||||
def test_setVariantByIdExists(global_stack, container_registry):
|
|
||||||
container_registry.return_value = getInstanceContainer(container_type = "variant")
|
|
||||||
global_stack.setVariantById("InstanceContainer")
|
|
||||||
assert global_stack.variant.getId() == "InstanceContainer"
|
|
||||||
|
|
||||||
## Tests setting variants by specifying an ID of a variant that doesn't exist.
|
|
||||||
def test_setVariantByIdDoesntExist(global_stack):
|
|
||||||
with pytest.raises(InvalidContainerError):
|
|
||||||
global_stack.setVariantById("some_variant") #Container registry is empty now.
|
|
||||||
|
|
||||||
## Smoke test for findDefaultVariant
|
## Smoke test for findDefaultVariant
|
||||||
def test_smoke_findDefaultVariant(global_stack):
|
def test_smoke_findDefaultVariant(global_stack):
|
||||||
global_stack.findDefaultVariant()
|
global_stack.findDefaultVariant()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue