From fce7cd3eb450dcbbffe99effa20c59df873abb9f Mon Sep 17 00:00:00 2001 From: Petru Conduraru Date: Thu, 25 Jun 2026 12:33:27 +0300 Subject: [PATCH] test(ifcpatch): add MergeProjects regression test for merging 3+ files (#7973) Merging more than two IFC models with the MergeProjects recipe leaves duplicated IfcGeometricRepresentationContext entities behind. All elements are kept, but the accumulated contexts cause later disciplines to appear "not merged" in viewers. This test merges three projects and asserts the elements are kept, a single IfcProject remains, and the geometric contexts are reused rather than accumulated. It currently fails on the context assertion, reproducing #7973. Co-Authored-By: Claude Opus 4.8 --- src/ifcpatch/test/test_MergeProject.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/ifcpatch/test/test_MergeProject.py b/src/ifcpatch/test/test_MergeProject.py index 35fcb0719f..d323e7efd4 100644 --- a/src/ifcpatch/test/test_MergeProject.py +++ b/src/ifcpatch/test/test_MergeProject.py @@ -177,6 +177,28 @@ class TestMergeProjects(test.bootstrap.IFC4): assert np.any(np.all(np.isclose(np.array((17.847, 24.707, 3.0)), verts, atol=1e-3), axis=1)) assert np.any(np.all(np.isclose(np.array((20.410, 25.902, 5.0)), verts, atol=1e-3), axis=1)) + def test_merging_three_or_more_projects(self): + # Regression test for #7973: merging N>2 models must keep every + # project's elements and must not leave duplicated geometric contexts + # behind (which makes later disciplines appear "not merged" in viewers). + self.file = self.setup_project(self.file) + second_file = self.setup_project() + third_file = self.setup_project() + output = ifcpatch.execute( + { + "file": self.file, + "recipe": "MergeProjects", + "arguments": [[second_file, third_file]], + } + ) + assert self.file == output + # Every model contributed exactly one wall. + assert len(output.by_type("IfcWall")) == 3 + # A single merged project must remain. + assert len(output.by_type("IfcProject")) == 1 + # Contexts must be reused, not accumulated: one Model + one Body. + assert len(output.by_type("IfcGeometricRepresentationContext")) == 2 + class TestMergeProjectsIFC2X3(test.bootstrap.IFC2X3, TestMergeProjects): pass