test_copy_work_schedule - cover ifc2x3 support

This commit is contained in:
Andrej730
2025-07-25 12:04:39 +05:00
parent dd1c47f9dc
commit 1d789da066
3 changed files with 13 additions and 7 deletions
@@ -71,10 +71,11 @@ def add_work_plan(
work_plan.Creators = [user.ThePerson]
work_plan.StartTime = ifcopenshell.api.sequence.add_date_time(file, datetime.now())
context = file.by_type("IfcContext")[0]
ifcopenshell.api.project.assign_declaration(
file,
definitions=[work_plan],
relating_context=context,
)
if file.schema != "IFC2X3":
context = file.by_type("IfcContext")[0]
ifcopenshell.api.project.assign_declaration(
file,
definitions=[work_plan],
relating_context=context,
)
return work_plan
@@ -18,6 +18,7 @@
import datetime
import ifcopenshell.util.date
import ifcopenshell.util.element
from math import floor
from functools import cache
from typing import Union, Literal, Optional
@@ -280,7 +281,7 @@ def get_task_work_schedule(task: ifcopenshell.entity_instance) -> Union[ifcopens
def get_nested_tasks(task: ifcopenshell.entity_instance) -> list[ifcopenshell.entity_instance]:
return [object for rel in task.IsNestedBy or [] for object in rel.RelatedObjects if object.is_a("IfcTask")]
return [obj for obj in ifcopenshell.util.element.get_components(task) if obj.is_a("IfcTask")]
def get_parent_task(task: ifcopenshell.entity_instance) -> Union[ifcopenshell.entity_instance, None]:
@@ -43,5 +43,9 @@ class TestCopyWorkSchedule(test.bootstrap.IFC4):
assert len(new_tasks.intersection(old_cost_items)) == 0
class TestCopyWorkScheduleIFC2X3(test.bootstrap.IFC2X3, TestCopyWorkSchedule):
pass
class TestCopyWorkScheduleIFC4X3(test.bootstrap.IFC4X3, TestCopyWorkSchedule):
pass