Fix bug in date calculations when editing task times without sufficient data

This commit is contained in:
Dion Moult
2022-02-23 13:08:52 +11:00
parent deb0597000
commit ccc6f2c4c6
2 changed files with 23 additions and 3 deletions
@@ -88,6 +88,26 @@ class TestEditTaskTime(test.bootstrap.IFC4):
assert task_time.ScheduleFinish is None
assert task_time.ScheduleDuration is None
def test_editing_just_a_start_date_with_no_duration_or_finish_but_with_a_calendar(self):
ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
calendar = ifcopenshell.api.run("sequence.add_work_calendar", self.file)
task = self.file.createIfcTask()
ifcopenshell.api.run("control.assign_control", self.file, relating_control=calendar, related_object=task)
task_time = ifcopenshell.api.run("sequence.add_task_time", self.file, task=task)
ifcopenshell.api.run(
"sequence.edit_task_time",
self.file,
task_time=task_time,
attributes={
"ScheduleDuration": None,
"ScheduleStart": datetime.datetime(2000, 1, 1),
"ScheduleFinish": None,
},
)
assert task_time.ScheduleStart == "2000-01-01T00:00:00"
assert task_time.ScheduleFinish is None
assert task_time.ScheduleDuration is None
def test_schedule_finish_dates_are_auto_calculated_if_possible(self):
task_time = ifcopenshell.api.run("sequence.add_task_time", self.file, task=self.file.createIfcTask())
ifcopenshell.api.run(