mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-09 21:53:40 +00:00
adapted to get pytest -p no:pytest-blender test/core/test_document.py working. Black formating
This commit is contained in:
@@ -16,7 +16,6 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Bonsai. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
import bonsai.core.document as subject
|
||||
from test.core.bootstrap import ifc, document
|
||||
|
||||
@@ -29,14 +28,6 @@ class TestLoadProjectDocuments:
|
||||
subject.load_project_documents(document)
|
||||
|
||||
|
||||
class TestLoadDocument:
|
||||
def test_run(self, document):
|
||||
document.clear_document_tree().should_be_called()
|
||||
document.disable_editing_document().should_be_called()
|
||||
document.add_breadcrumb("document").should_be_called()
|
||||
subject.load_document(document, document="document")
|
||||
|
||||
|
||||
class TestDisableDocumentEditingUi:
|
||||
def test_run(self, document):
|
||||
document.disable_editing_ui().should_be_called()
|
||||
@@ -44,38 +35,71 @@ class TestDisableDocumentEditingUi:
|
||||
subject.disable_document_editing_ui(document)
|
||||
|
||||
|
||||
class TestDisableObjectDocumentEditingUi:
|
||||
def test_run(self, document):
|
||||
document.disable_object_editing_ui().should_be_called()
|
||||
subject.disable_object_document_editing_ui(document)
|
||||
|
||||
|
||||
class TestEnableEditingDocument:
|
||||
def test_run(self, document):
|
||||
document.import_document_attributes("document").should_be_called()
|
||||
document.set_active_document("document").should_be_called()
|
||||
subject.enable_editing_document(document, document="document")
|
||||
document.import_document_attributes("document").should_be_called()
|
||||
subject.enable_editing_document(document, ifc_document="document")
|
||||
|
||||
|
||||
class TestDisableEditingDocument:
|
||||
def test_run(self, document):
|
||||
document.disable_editing_document().should_be_called()
|
||||
document.clear_active_document().should_be_called()
|
||||
document.clear_document_attributes().should_be_called()
|
||||
subject.disable_editing_document(document)
|
||||
|
||||
|
||||
class TestAddInformation:
|
||||
def test_add_and_reload_tree_at_project_root(self, ifc, document):
|
||||
document.clear_document_tree().should_be_called()
|
||||
ifc.run("document.add_information", parent=None).should_be_called().will_return("information")
|
||||
document.get_default_parent_for_information().should_be_called().will_return("default_parent")
|
||||
ifc.run("document.add_information", parent="default_parent").should_be_called().will_return("information")
|
||||
ifc.run("document.add_reference", information="information").should_be_called()
|
||||
document.is_document_information("default_parent").should_be_called().will_return(True)
|
||||
document.expand_document("default_parent").should_be_called()
|
||||
document.import_project_documents().should_be_called()
|
||||
|
||||
subject.add_information(ifc, document)
|
||||
|
||||
def test_add_and_reload_tree_at_current_parent(self, ifc, document):
|
||||
document.clear_document_tree().should_be_called()
|
||||
ifc.run("document.add_information", parent="parent").should_be_called().will_return("information")
|
||||
ifc.run("document.add_reference", information="information").should_be_called()
|
||||
subject.add_information(ifc, document)
|
||||
document.is_document_information("parent").should_be_called().will_return(True)
|
||||
document.expand_document("parent").should_be_called()
|
||||
document.import_project_documents().should_be_called()
|
||||
|
||||
subject.add_information(ifc, document, parent="parent")
|
||||
|
||||
def test_add_without_expanding_if_parent_is_not_information(self, ifc, document):
|
||||
document.clear_document_tree().should_be_called()
|
||||
ifc.run("document.add_information", parent="parent").should_be_called().will_return("information")
|
||||
ifc.run("document.add_reference", information="information").should_be_called()
|
||||
document.is_document_information("parent").should_be_called().will_return(False)
|
||||
document.import_project_documents().should_be_called()
|
||||
|
||||
subject.add_information(ifc, document, parent="parent")
|
||||
|
||||
|
||||
class TestAddReference:
|
||||
def test_run(self, ifc, document):
|
||||
def test_run_with_selected_parent(self, ifc, document):
|
||||
document.get_selected_document_information().should_be_called().will_return("parent")
|
||||
ifc.run("document.add_reference", information="parent").should_be_called()
|
||||
document.clear_document_tree().should_be_called()
|
||||
document.expand_document("parent").should_be_called()
|
||||
document.import_project_documents().should_be_called()
|
||||
|
||||
subject.add_reference(ifc, document)
|
||||
|
||||
def test_run_without_selected_parent(self, ifc, document):
|
||||
document.get_selected_document_information().should_be_called().will_return(None)
|
||||
document.import_project_documents().should_be_called()
|
||||
|
||||
subject.add_reference(ifc, document)
|
||||
|
||||
|
||||
@@ -87,7 +111,7 @@ class TestEditDocument:
|
||||
document.disable_editing_document().should_be_called()
|
||||
document.clear_document_tree().should_be_called()
|
||||
document.import_project_documents().should_be_called()
|
||||
subject.edit_document(ifc, document, document="document")
|
||||
subject.edit_document(ifc, document, ifc_document="document")
|
||||
|
||||
def test_edit_reference(self, ifc, document):
|
||||
document.export_document_attributes().should_be_called().will_return("attributes")
|
||||
@@ -95,7 +119,8 @@ class TestEditDocument:
|
||||
ifc.run("document.edit_reference", reference="document", attributes="attributes").should_be_called()
|
||||
document.disable_editing_document().should_be_called()
|
||||
document.clear_document_tree().should_be_called()
|
||||
subject.edit_document(ifc, document, document="document")
|
||||
document.import_project_documents().should_be_called()
|
||||
subject.edit_document(ifc, document, ifc_document="document")
|
||||
|
||||
|
||||
class TestRemoveDocument:
|
||||
@@ -104,22 +129,23 @@ class TestRemoveDocument:
|
||||
document.is_document_information("document").should_be_called().will_return(True)
|
||||
ifc.run("document.remove_information", information="document").should_be_called()
|
||||
document.import_project_documents().should_be_called()
|
||||
subject.remove_document(ifc, document, document="document")
|
||||
subject.remove_document(ifc, document, ifc_document="document")
|
||||
|
||||
def test_remove_reference(self, ifc, document):
|
||||
document.clear_document_tree().should_be_called()
|
||||
document.is_document_information("document").should_be_called().will_return(False)
|
||||
ifc.run("document.remove_reference", reference="document").should_be_called()
|
||||
subject.remove_document(ifc, document, document="document")
|
||||
document.import_project_documents().should_be_called()
|
||||
subject.remove_document(ifc, document, ifc_document="document")
|
||||
|
||||
|
||||
class TestAssignDocument:
|
||||
def test_run(self, ifc):
|
||||
ifc.run("document.assign_document", products=["product"], document="document").should_be_called()
|
||||
subject.assign_document(ifc, product="product", document="document")
|
||||
subject.assign_document(ifc, product="product", ifc_document="document")
|
||||
|
||||
|
||||
class TestUnassignDocument:
|
||||
def test_run(self, ifc):
|
||||
ifc.run("document.unassign_document", products=["product"], document="document").should_be_called()
|
||||
subject.unassign_document(ifc, product="product", document="document")
|
||||
subject.unassign_document(ifc, product="product", ifc_document="document")
|
||||
|
||||
Reference in New Issue
Block a user