|
17 | 17 | # along with BlenderBIM Add-on. If not, see <http://www.gnu.org/licenses/>. |
18 | 18 |
|
19 | 19 | import blenderbim.core.type as subject |
20 | | -from test.core.bootstrap import ifc, geometry, type |
| 20 | +from test.core.bootstrap import ifc, type |
21 | 21 |
|
22 | 22 |
|
23 | 23 | class TestAssignType: |
24 | | - def test_assigning_and_switching_preferably_to_a_body_representation(self, ifc, geometry, type): |
| 24 | + def test_assigning_and_switching_preferably_to_a_body_representation(self, ifc, type): |
25 | 25 | ifc.run("type.assign_type", related_object="element", relating_type="type").should_be_called() |
| 26 | + type.has_material_usage("element").should_be_called().will_return(False) |
26 | 27 | type.get_body_representation("element").should_be_called().will_return("mapped_rep") |
27 | 28 | ifc.get_object("element").should_be_called().will_return("obj") |
28 | 29 | type.has_dynamic_voids("obj").should_be_called().will_return(False) |
29 | | - |
30 | | - geometry.resolve_mapped_representation("mapped_rep").should_be_called().will_return("representation") |
31 | | - geometry.get_representation_data("representation").should_be_called().will_return("data") |
32 | | - geometry.change_object_data("obj", "data", is_global=False).should_be_called() |
33 | | - geometry.clear_dynamic_voids("obj").should_be_called() |
34 | | - |
| 30 | + type.run_geometry_switch_representation( |
| 31 | + obj="obj", representation="mapped_rep", should_reload=False, enable_dynamic_voids=False, is_global=False |
| 32 | + ).should_be_called() |
35 | 33 | type.disable_editing("obj").should_be_called() |
| 34 | + subject.assign_type(ifc, type, element="element", type="type") |
36 | 35 |
|
37 | | - subject.assign_type(ifc, geometry, type, element="element", type="type") |
38 | | - |
39 | | - def test_assigning_and_switching_to_any_representation_as_a_fallback(self, ifc, geometry, type): |
| 36 | + def test_assigning_and_switching_to_any_representation_as_a_fallback(self, ifc, type): |
40 | 37 | ifc.run("type.assign_type", related_object="element", relating_type="type").should_be_called() |
| 38 | + type.has_material_usage("element").should_be_called().will_return(False) |
41 | 39 | type.get_body_representation("element").should_be_called().will_return(None) |
42 | 40 | type.get_any_representation("element").should_be_called().will_return("mapped_rep") |
43 | 41 | ifc.get_object("element").should_be_called().will_return("obj") |
44 | 42 | type.has_dynamic_voids("obj").should_be_called().will_return(False) |
| 43 | + type.run_geometry_switch_representation( |
| 44 | + obj="obj", representation="mapped_rep", should_reload=False, enable_dynamic_voids=False, is_global=False |
| 45 | + ).should_be_called() |
| 46 | + type.disable_editing("obj").should_be_called() |
| 47 | + subject.assign_type(ifc, type, element="element", type="type") |
45 | 48 |
|
46 | | - geometry.resolve_mapped_representation("mapped_rep").should_be_called().will_return("representation") |
47 | | - geometry.get_representation_data("representation").should_be_called().will_return("data") |
48 | | - geometry.change_object_data("obj", "data", is_global=False).should_be_called() |
49 | | - geometry.clear_dynamic_voids("obj").should_be_called() |
50 | | - |
| 49 | + def test_assigning_and_not_changing_representation_if_there_is_no_representation_to_change_to(self, ifc, type): |
| 50 | + ifc.run("type.assign_type", related_object="element", relating_type="type").should_be_called() |
| 51 | + type.has_material_usage("element").should_be_called().will_return(False) |
| 52 | + type.get_body_representation("element").should_be_called().will_return(None) |
| 53 | + type.get_any_representation("element").should_be_called().will_return(None) |
| 54 | + ifc.get_object("element").should_be_called().will_return("obj") |
51 | 55 | type.disable_editing("obj").should_be_called() |
| 56 | + subject.assign_type(ifc, type, element="element", type="type") |
52 | 57 |
|
53 | | - subject.assign_type(ifc, geometry, type, element="element", type="type") |
| 58 | + def test_updating_an_existing_body_if_there_is_a_parametric_material_usage(self, ifc, type): |
| 59 | + ifc.run("type.assign_type", related_object="element", relating_type="type").should_be_called() |
54 | 60 |
|
55 | | - def test_assigning_and_not_changing_representation_if_not_available(self, ifc, type): |
| 61 | + type.has_material_usage("element").should_be_called().will_return(True) |
| 62 | + type.get_body_representation("element").should_be_called().will_return("representation") |
| 63 | + type.get_representation_context("representation").should_be_called().will_return("context") |
| 64 | + ifc.run( |
| 65 | + "geometry.unassign_representation", product="element", representation="representation" |
| 66 | + ).should_be_called() |
| 67 | + ifc.run("geometry.remove_representation", representation="representation").should_be_called() |
| 68 | + type.get_ifc_representation_class("element").should_be_called().will_return("class") |
| 69 | + type.get_profile_set_usage("element").should_be_called().will_return("usage") |
| 70 | + type.run_geometry_add_representation( |
| 71 | + obj="obj", context="context", ifc_representation_class="class", profile_set_usage="usage" |
| 72 | + ).should_be_called().will_return("mapped_rep") |
| 73 | + |
| 74 | + ifc.get_object("element").should_be_called().will_return("obj") |
| 75 | + type.has_dynamic_voids("obj").should_be_called().will_return(False) |
| 76 | + type.run_geometry_switch_representation( |
| 77 | + obj="obj", representation="mapped_rep", should_reload=True, enable_dynamic_voids=False, is_global=False |
| 78 | + ).should_be_called() |
| 79 | + type.disable_editing("obj").should_be_called() |
| 80 | + subject.assign_type(ifc, type, element="element", type="type") |
| 81 | + |
| 82 | + def test_creating_a_new_body_if_there_is_a_parametric_material_usage(self, ifc, type): |
56 | 83 | ifc.run("type.assign_type", related_object="element", relating_type="type").should_be_called() |
| 84 | + |
| 85 | + type.has_material_usage("element").should_be_called().will_return(True) |
57 | 86 | type.get_body_representation("element").should_be_called().will_return(None) |
58 | | - type.get_any_representation("element").should_be_called().will_return(None) |
| 87 | + type.get_body_context().should_be_called().will_return("context") |
| 88 | + type.get_ifc_representation_class("element").should_be_called().will_return("class") |
| 89 | + type.get_profile_set_usage("element").should_be_called().will_return("usage") |
| 90 | + type.run_geometry_add_representation( |
| 91 | + obj="obj", context="context", ifc_representation_class="class", profile_set_usage="usage" |
| 92 | + ).should_be_called().will_return("mapped_rep") |
| 93 | + |
59 | 94 | ifc.get_object("element").should_be_called().will_return("obj") |
| 95 | + type.has_dynamic_voids("obj").should_be_called().will_return(False) |
| 96 | + type.run_geometry_switch_representation( |
| 97 | + obj="obj", representation="mapped_rep", should_reload=True, enable_dynamic_voids=False, is_global=False |
| 98 | + ).should_be_called() |
60 | 99 | type.disable_editing("obj").should_be_called() |
61 | | - subject.assign_type(ifc, geometry, type, element="element", type="type") |
| 100 | + subject.assign_type(ifc, type, element="element", type="type") |
0 commit comments