Organisations now support null attributes.

This commit is contained in:
Dion Moult
2021-09-29 18:39:10 +10:00
parent 406fd158d3
commit beff90cd5e
16 changed files with 454 additions and 315 deletions
+2 -1
View File
@@ -95,6 +95,7 @@ def additionally_the_object_name_is_selected(name):
bpy.context.view_layer.objects.active = obj
obj.select_set(True)
def i_deselect_all_objects():
bpy.context.view_layer.objects.active = None
bpy.ops.object.select_all(action="DESELECT")
@@ -346,7 +347,7 @@ definitions = {
'I add a cube of size "([0-9]+)" at "(.*)"': i_add_a_cube_of_size_size_at_location,
'the object "(.*)" is selected': the_object_name_is_selected,
'additionally the object "(.*)" is selected': additionally_the_object_name_is_selected,
'I deselect all objects': i_deselect_all_objects,
"I deselect all objects": i_deselect_all_objects,
'I am on frame "([0-9]+)"': i_am_on_frame_number,
'I set "(.*)" to "(.*)"': i_set_prop_to_value,
'"(.*)" is "(.*)"': prop_is_value,
@@ -165,3 +165,38 @@ Scenario: Edit address
And I press "bim.enable_editing_address(address={address})"
And I press "bim.edit_address()"
Then nothing happens
Scenario: Add organisation
Given an empty IFC project
When I press "bim.add_organisation"
Then nothing happens
Scenario: Enable editing organisation
Given an empty IFC project
When I press "bim.add_organisation"
And the variable "organisation" is "{ifc}.by_type('IfcOrganization')[0].id()"
And I press "bim.enable_editing_organisation(organisation={organisation})"
Then "scene.BIMOwnerProperties.active_organisation_id" is "{organisation}"
Scenario: Disable editing organisation
Given an empty IFC project
When I press "bim.add_organisation"
And the variable "organisation" is "{ifc}.by_type('IfcOrganization')[0].id()"
And I press "bim.enable_editing_organisation(organisation={organisation})"
And I press "bim.disable_editing_organisation"
Then "scene.BIMOwnerProperties.active_organisation_id" is "0"
Scenario: Edit organisation
Given an empty IFC project
When I press "bim.add_organisation"
And the variable "organisation" is "{ifc}.by_type('IfcOrganization')[0].id()"
And I press "bim.enable_editing_organisation(organisation={organisation})"
And I press "bim.edit_organisation"
Then "scene.BIMOwnerProperties.active_organisation_id" is "0"
Scenario: Remove organisation
Given an empty IFC project
When I press "bim.add_organisation"
And the variable "organisation" is "{ifc}.by_type('IfcOrganization')[0].id()"
And I press "bim.remove_organisation(organisation={organisation})"
Then nothing happens
@@ -382,7 +382,7 @@ class TestRemoveFilling(test.bim.bootstrap.NewFile):
And I delete the selected objects
Then the object "IfcOpeningElement/Cube" is an "IfcOpeningElement"
And the void "IfcOpeningElement/Cube" is not filled by "Cube"
"""
"""
@test.bim.bootstrap.scenario
def test_removing_a_filling_using_deletion_on_the_opening(self):
+7
View File
@@ -56,6 +56,13 @@ def address_editor():
prophet.verify()
@pytest.fixture
def organisation_editor():
prophet = Prophecy(blenderbim.core.tool.OrganisationEditor)
yield prophet
prophet.verify()
class Prophecy:
def __init__(self, cls):
self.subject = cls
+35 -1
View File
@@ -18,7 +18,7 @@
import blenderbim.core.owner as subject
from test.core.bootstrap import ifc, blender, person_editor, role_editor, address_editor
from test.core.bootstrap import ifc, blender, person_editor, role_editor, address_editor, organisation_editor
class TestAddPerson:
@@ -147,3 +147,37 @@ class TestRemoveAddressAttribute:
def test_run(self, address_editor):
address_editor.remove_attribute("name", "id").should_be_called()
subject.remove_address_attribute(address_editor, name="name", id="id")
class TestAddOrganisation:
def test_run(self, ifc):
ifc.run("owner.add_organisation").should_be_called().will_return("organisation")
assert subject.add_organisation(ifc) == "organisation"
class TestRemoveOrganisation:
def test_run(self, ifc):
ifc.run("owner.remove_organisation", organisation="organisation").should_be_called()
subject.remove_organisation(ifc, organisation="organisation")
class TestEnableEditingOrganisation:
def test_run(self, organisation_editor):
organisation_editor.set_organisation("organisation").should_be_called()
organisation_editor.import_attributes().should_be_called()
subject.enable_editing_organisation(organisation_editor, organisation="organisation")
class TestDisableEditingOrganisation:
def test_run(self, organisation_editor):
organisation_editor.clear_organisation().should_be_called()
subject.disable_editing_organisation(organisation_editor)
class TestEditOrganisation:
def test_run(self, ifc, organisation_editor):
organisation_editor.get_organisation().should_be_called().will_return("organisation")
organisation_editor.export_attributes().should_be_called().will_return("attributes")
ifc.run("owner.edit_organisation", organisation="organisation", attributes="attributes").should_be_called()
organisation_editor.clear_organisation().should_be_called()
subject.edit_organisation(ifc, organisation_editor)
@@ -0,0 +1,94 @@
# BlenderBIM Add-on - OpenBIM Blender Add-on
# Copyright (C) 2021 Dion Moult <dion@thinkmoult.com>
#
# This file is part of BlenderBIM Add-on.
#
# BlenderBIM Add-on is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# BlenderBIM Add-on is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with BlenderBIM Add-on. If not, see <http://www.gnu.org/licenses/>.
import bpy
import ifcopenshell
import test.bim.bootstrap
import blenderbim.core.tool
import blenderbim.tool as tool
from blenderbim.tool.organisation_editor import OrganisationEditor as subject
class TestImplementsTool(test.bim.bootstrap.NewFile):
def test_run(self):
assert isinstance(subject(), blenderbim.core.tool.organisation_editor.OrganisationEditor)
class TestSetOrganisation(test.bim.bootstrap.NewFile):
def test_run(self):
organisation = ifcopenshell.file().createIfcOrganization()
subject().set_organisation(organisation)
assert bpy.context.scene.BIMOwnerProperties.active_organisation_id == organisation.id()
class TestImportAttributes(test.bim.bootstrap.NewFile):
def test_run(self):
ifc = ifcopenshell.file()
tool.Ifc().set(ifc)
organisation = ifc.createIfcOrganization()
organisation.Identification = "Identification"
organisation.Name = "Name"
organisation.Description = "Description"
subject().set_organisation(organisation)
subject().import_attributes()
props = bpy.context.scene.BIMOwnerProperties
assert props.organisation_attributes.get("Identification").string_value == "Identification"
assert props.organisation_attributes.get("Name").string_value == "Name"
assert props.organisation_attributes.get("Description").string_value == "Description"
def test_overwriting_a_previous_import(self):
ifc = ifcopenshell.file()
tool.Ifc().set(ifc)
organisation = ifc.createIfcOrganization()
organisation.Identification = "Identification"
organisation.Description = "Description"
subject().set_organisation(organisation)
subject().import_attributes()
organisation.Identification = "Identification2"
organisation.Description = None
subject().import_attributes()
props = bpy.context.scene.BIMOwnerProperties
assert props.organisation_attributes.get("Identification").string_value == "Identification2"
assert props.organisation_attributes.get("Description").string_value == ""
class TestClearOrganisation(test.bim.bootstrap.NewFile):
def test_run(self):
props = bpy.context.scene.BIMOwnerProperties
props.active_organisation_id = 1
subject().clear_organisation()
assert props.active_organisation_id == 0
class TestExportAttributes(test.bim.bootstrap.NewFile):
def test_run(self):
TestImportAttributes().test_run()
assert subject().export_attributes() == {
"Identification": "Identification",
"Name": "Name",
"Description": "Description",
}
class TestGetOrganisation(test.bim.bootstrap.NewFile):
def test_run(self):
ifc = ifcopenshell.file()
tool.Ifc().set(ifc)
organisation = ifc.createIfcOrganization()
subject().set_organisation(organisation)
assert subject().get_organisation() == organisation