mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-16 10:34:31 +00:00
New UI to add / edit / remove library information and references.
This commit is contained in:
@@ -77,6 +77,13 @@ def geometry():
|
||||
prophet.verify()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def library():
|
||||
prophet = Prophecy(blenderbim.core.tool.Library)
|
||||
yield prophet
|
||||
prophet.verify()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def material():
|
||||
prophet = Prophecy(blenderbim.core.tool.Material)
|
||||
|
||||
@@ -0,0 +1,111 @@
|
||||
# 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 blenderbim.core.library as subject
|
||||
from test.core.bootstrap import ifc, library
|
||||
|
||||
|
||||
class TestAddLibrary:
|
||||
def test_run(self, ifc):
|
||||
ifc.run("library.add_library", name="Unnamed").should_be_called().will_return("library")
|
||||
assert subject.add_library(ifc) == "library"
|
||||
|
||||
|
||||
class TestRemoveLibrary:
|
||||
def test_run(self, ifc):
|
||||
ifc.run("library.remove_library", library="library").should_be_called()
|
||||
subject.remove_library(ifc, library="library")
|
||||
|
||||
|
||||
class TestEnableEditingLibraryReferences:
|
||||
def test_run(self, library):
|
||||
library.set_editing_mode("REFERENCES").should_be_called()
|
||||
library.set_active_library("library").should_be_called()
|
||||
library.import_references("library").should_be_called()
|
||||
subject.enable_editing_library_references(library, library="library")
|
||||
|
||||
|
||||
class TestDisableEditingLibraryReferences:
|
||||
def test_run(self, library):
|
||||
library.clear_editing_mode().should_be_called()
|
||||
subject.disable_editing_library_references(library)
|
||||
|
||||
|
||||
class TestEnableEditingLibrary:
|
||||
def test_run(self, library):
|
||||
library.set_editing_mode("LIBRARY").should_be_called()
|
||||
library.get_active_library().should_be_called().will_return("library")
|
||||
library.import_library_attributes("library").should_be_called()
|
||||
subject.enable_editing_library(library)
|
||||
|
||||
|
||||
class TestDisableEditingLibrary:
|
||||
def test_run(self, library):
|
||||
library.set_editing_mode("REFERENCES").should_be_called()
|
||||
subject.disable_editing_library(library)
|
||||
|
||||
|
||||
class TestEditLibrary:
|
||||
def test_run(self, ifc, library):
|
||||
library.set_editing_mode("REFERENCES").should_be_called()
|
||||
library.get_active_library().should_be_called().will_return("library")
|
||||
library.export_library_attributes().should_be_called().will_return("attributes")
|
||||
ifc.run("library.edit_library", library="library", attributes="attributes").should_be_called()
|
||||
library.import_references("library").should_be_called()
|
||||
subject.edit_library(ifc, library)
|
||||
|
||||
|
||||
class TestAddLibraryReference:
|
||||
def test_run(self, ifc, library):
|
||||
library.get_active_library().should_be_called().will_return("library")
|
||||
ifc.run("library.add_reference", library="library").should_be_called()
|
||||
library.import_references("library").should_be_called()
|
||||
subject.add_library_reference(ifc, library)
|
||||
|
||||
|
||||
class TestRemoveLibraryReference:
|
||||
def test_run(self, ifc, library):
|
||||
ifc.run("library.remove_reference", reference="reference").should_be_called()
|
||||
library.get_active_library().should_be_called().will_return("library")
|
||||
library.import_references("library").should_be_called()
|
||||
subject.remove_library_reference(ifc, library, reference="reference")
|
||||
|
||||
|
||||
class TestEnableEditingLibraryReference:
|
||||
def test_run(self, library):
|
||||
library.set_editing_mode("REFERENCE").should_be_called()
|
||||
library.set_active_reference("reference").should_be_called()
|
||||
library.import_reference_attributes("reference").should_be_called()
|
||||
subject.enable_editing_library_reference(library, reference="reference")
|
||||
|
||||
|
||||
class TestDisableEditingLibraryReference:
|
||||
def test_run(self, library):
|
||||
library.set_editing_mode("REFERENCES").should_be_called()
|
||||
subject.disable_editing_library_reference(library)
|
||||
|
||||
|
||||
class TestEditLibraryReference:
|
||||
def test_run(self, ifc, library):
|
||||
library.set_editing_mode("REFERENCES").should_be_called()
|
||||
library.get_active_reference().should_be_called().will_return("reference")
|
||||
library.export_reference_attributes().should_be_called().will_return("attributes")
|
||||
ifc.run("library.edit_reference", reference="reference", attributes="attributes").should_be_called()
|
||||
library.get_active_library().should_be_called().will_return("library")
|
||||
library.import_references("library").should_be_called()
|
||||
subject.edit_library_reference(ifc, library)
|
||||
Reference in New Issue
Block a user