From e38184b152fcf1f51d81337b4984a11a5b79da36 Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Wed, 30 Mar 2022 18:15:26 +1100 Subject: [PATCH] Adding a document now auto adds a reference for convenience. --- src/blenderbim/blenderbim/core/document.py | 3 ++- src/blenderbim/test/core/test_document.py | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/blenderbim/blenderbim/core/document.py b/src/blenderbim/blenderbim/core/document.py index 873af9e642..ce6dc374c6 100644 --- a/src/blenderbim/blenderbim/core/document.py +++ b/src/blenderbim/blenderbim/core/document.py @@ -61,7 +61,8 @@ def disable_editing_document(document): def add_information(ifc, document): document.clear_document_tree() parent = document.get_active_breadcrumb() - ifc.run("document.add_information", parent=parent) + information = ifc.run("document.add_information", parent=parent) + ifc.run("document.add_reference", information=information) if parent: document.import_subdocuments(parent) document.import_references(parent) diff --git a/src/blenderbim/test/core/test_document.py b/src/blenderbim/test/core/test_document.py index e2ddfe7f45..708c899e48 100644 --- a/src/blenderbim/test/core/test_document.py +++ b/src/blenderbim/test/core/test_document.py @@ -64,14 +64,16 @@ class TestAddInformation: def test_add_and_reload_tree_at_project_root(self, ifc, document): document.clear_document_tree().should_be_called() document.get_active_breadcrumb().should_be_called().will_return(None) - ifc.run("document.add_information", parent=None).should_be_called() + ifc.run("document.add_information", parent=None).should_be_called().will_return("information") + ifc.run("document.add_reference", information="information").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() document.get_active_breadcrumb().should_be_called().will_return("parent") - ifc.run("document.add_information", parent="parent").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.import_subdocuments("parent").should_be_called() document.import_references("parent").should_be_called() subject.add_information(ifc, document)