Fix #2611. Address multiple situations in the UI where the users could create invalid material data without an indication that it is invalid.

This commit is contained in:
Dion Moult
2023-02-05 17:09:13 +11:00
parent 77234706b0
commit ccd7db06f8
8 changed files with 258 additions and 11 deletions
@@ -94,6 +94,7 @@ class TestAddMaterialSet:
class TestRemoveMaterial:
def test_removing_a_material(self, ifc, material, style):
material.is_material_used_in_sets("material").should_be_called().will_return(False)
ifc.get_object("material").should_be_called().will_return(None)
ifc.unlink(element="material").should_be_called()
ifc.run("material.remove_material", material="material").should_be_called()
@@ -101,6 +102,7 @@ class TestRemoveMaterial:
subject.remove_material(ifc, material, style, material="material")
def test_removing_a_material_and_reloading_imported_materials(self, ifc, material, style):
material.is_material_used_in_sets("material").should_be_called().will_return(False)
ifc.get_object("material").should_be_called().will_return(None)
ifc.unlink(element="material").should_be_called()
ifc.run("material.remove_material", material="material").should_be_called()
@@ -110,6 +112,7 @@ class TestRemoveMaterial:
subject.remove_material(ifc, material, style, material="material")
def test_removing_a_material_object_if_it_has_no_style(self, ifc, material, style):
material.is_material_used_in_sets("material").should_be_called().will_return(False)
ifc.get_object("material").should_be_called().will_return("obj")
ifc.unlink(element="material").should_be_called()
ifc.run("material.remove_material", material="material").should_be_called()
@@ -119,6 +122,7 @@ class TestRemoveMaterial:
subject.remove_material(ifc, material, style, material="material")
def test_preserving_a_material_object_if_it_is_still_used_as_a_style(self, ifc, material, style):
material.is_material_used_in_sets("material").should_be_called().will_return(False)
ifc.get_object("material").should_be_called().will_return("obj")
ifc.unlink(element="material").should_be_called()
ifc.run("material.remove_material", material="material").should_be_called()
@@ -126,6 +130,10 @@ class TestRemoveMaterial:
material.is_editing_materials().should_be_called().will_return(False)
subject.remove_material(ifc, material, style, material="material")
def test_not_removing_a_material_if_it_is_used_in_a_material_set(self, ifc, material, style):
material.is_material_used_in_sets("material").should_be_called().will_return(True)
subject.remove_material(ifc, material, style, material="material")
class TestRemoveMaterialSet:
def test_run(self, ifc, material):