Fix bug with editing task start times without finishes

This commit is contained in:
Dion Moult
2022-02-23 12:28:34 +11:00
parent 9e22e9486a
commit 348373d47e
2 changed files with 17 additions and 1 deletions
@@ -65,7 +65,7 @@ class Usecase:
self.calculate_finish()
elif "ScheduleStart" in self.settings["attributes"].keys() and self.settings["task_time"].ScheduleDuration:
self.calculate_finish()
elif "ScheduleFinish" in self.settings["attributes"].keys() and self.settings["task_time"].ScheduleStart:
elif self.settings["attributes"].get("ScheduleFinish", None) and self.settings["task_time"].ScheduleStart:
self.calculate_duration()
if self.settings["task_time"].ScheduleDuration and (
@@ -72,6 +72,22 @@ class TestEditTaskTime(test.bootstrap.IFC4):
assert task_time.RemainingTime == "P1D"
assert task_time.Completion == 0.5
def test_editing_just_a_start_date_with_no_duration_or_finish(self):
task_time = ifcopenshell.api.run("sequence.add_task_time", self.file, task=self.file.createIfcTask())
ifcopenshell.api.run(
"sequence.edit_task_time",
self.file,
task_time=task_time,
attributes={
"ScheduleDuration": None,
"ScheduleStart": "2000-01-01T00:00:00",
"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(