mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 09:48:32 +00:00
Fix bug where you could assign a product twice to a process.
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
|
||||
|
||||
class TestAssignProduct(test.bootstrap.IFC4):
|
||||
def test_assigning_a_product(self):
|
||||
wall = self.file.createIfcWall()
|
||||
task = self.file.createIfcTask()
|
||||
task2 = self.file.createIfcTask()
|
||||
ifcopenshell.api.run("sequence.assign_product", self.file, relating_product=wall, related_object=task)
|
||||
assert wall.ReferencedBy[0].RelatedObjects == (task,)
|
||||
ifcopenshell.api.run("sequence.assign_product", self.file, relating_product=wall, related_object=task2)
|
||||
assert wall.ReferencedBy[0].RelatedObjects == (task, task2)
|
||||
|
||||
def test_not_assigning_twice(self):
|
||||
wall = self.file.createIfcWall()
|
||||
task = self.file.createIfcTask()
|
||||
ifcopenshell.api.run("sequence.assign_product", self.file, relating_product=wall, related_object=task)
|
||||
ifcopenshell.api.run("sequence.assign_product", self.file, relating_product=wall, related_object=task)
|
||||
assert wall.ReferencedBy[0].RelatedObjects == (task,)
|
||||
@@ -0,0 +1,11 @@
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
|
||||
|
||||
class TestUnassignProduct(test.bootstrap.IFC4):
|
||||
def test_unassigning_a_product(self):
|
||||
wall = self.file.createIfcWall()
|
||||
task = self.file.createIfcTask()
|
||||
ifcopenshell.api.run("sequence.assign_product", self.file, relating_product=wall, related_object=task)
|
||||
ifcopenshell.api.run("sequence.unassign_product", self.file, relating_product=wall, related_object=task)
|
||||
assert len(self.file.by_type("IfcRelAssignsToProduct")) == 0
|
||||
Reference in New Issue
Block a user