From 68a43b92eedcd4babd31f2ed0f48768776d9ce19 Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Fri, 21 Jan 2022 18:42:59 +1100 Subject: [PATCH] Editing task times no longer tries to be clever with actual dates because you know what you're doing. --- .../api/sequence/edit_task_time.py | 5 -- .../test/api/sequence/test_edit_task_time.py | 68 +++++++++++++++++++ 2 files changed, 68 insertions(+), 5 deletions(-) create mode 100644 src/ifcopenshell-python/test/api/sequence/test_edit_task_time.py diff --git a/src/ifcopenshell-python/ifcopenshell/api/sequence/edit_task_time.py b/src/ifcopenshell-python/ifcopenshell/api/sequence/edit_task_time.py index b63daa263f..f9f0dd4d5f 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/sequence/edit_task_time.py +++ b/src/ifcopenshell-python/ifcopenshell/api/sequence/edit_task_time.py @@ -38,11 +38,6 @@ class Usecase: and "ScheduleFinish" in self.settings["attributes"].keys() ): del self.settings["attributes"]["ScheduleFinish"] - if ( - self.settings["attributes"].get("ActualDuration", None) - and "ActualFinish" in self.settings["attributes"].keys() - ): - del self.settings["attributes"]["ActualFinish"] duration_type = self.settings["attributes"].get("DurationType", self.settings["task_time"].DurationType) if "ScheduleFinish" in self.settings["attributes"]: diff --git a/src/ifcopenshell-python/test/api/sequence/test_edit_task_time.py b/src/ifcopenshell-python/test/api/sequence/test_edit_task_time.py new file mode 100644 index 0000000000..a1e69295ae --- /dev/null +++ b/src/ifcopenshell-python/test/api/sequence/test_edit_task_time.py @@ -0,0 +1,68 @@ +# IfcOpenShell - IFC toolkit and geometry engine +# Copyright (C) 2022 Dion Moult +# +# This file is part of IfcOpenShell. +# +# IfcOpenShell is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# IfcOpenShell is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with IfcOpenShell. If not, see . + +import test.bootstrap +import ifcopenshell.api + + +class TestEditTaskTime(test.bootstrap.IFC4): + def test_editing_all_attributes(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={ + "Name": "Name", + "DataOrigin": "NOTDEFINED", + "UserDefinedDataOrigin": "UserDefinedDataOrigin", + "DurationType": "ELAPSEDTIME", + "ScheduleDuration": "P1D", + "ScheduleStart": "2000-01-01T00:00:00", + "ScheduleFinish": "2000-01-02T00:00:00", + "EarlyStart": "2000-01-01T00:00:00", + "EarlyFinish": "2000-01-02T00:00:00", + "LateStart": "2000-01-01T00:00:00", + "LateFinish": "2000-01-02T00:00:00", + "FreeFloat": "P0D", + "TotalFloat": "P0D", + "IsCritical": True, + "StatusTime": "2000-01-01T00:00:00", + "ActualDuration": "P1D", + "ActualStart": "2000-01-01T00:00:00", + "ActualFinish": "2000-01-02T00:00:00", + "RemainingTime": "P1D", + "Completion": 0.5, + + }) + assert task_time.Name == "Name" + assert task_time.DataOrigin == "NOTDEFINED" + assert task_time.UserDefinedDataOrigin == "UserDefinedDataOrigin" + assert task_time.DurationType == "ELAPSEDTIME" + assert task_time.ScheduleDuration == "P1D" + assert task_time.ScheduleStart == "2000-01-01T00:00:00" + assert task_time.ScheduleFinish == "2000-01-02T00:00:00" + assert task_time.EarlyStart == "2000-01-01T00:00:00" + assert task_time.EarlyFinish == "2000-01-02T00:00:00" + assert task_time.LateStart == "2000-01-01T00:00:00" + assert task_time.LateFinish == "2000-01-02T00:00:00" + assert task_time.FreeFloat == "P0D" + assert task_time.TotalFloat == "P0D" + assert task_time.IsCritical == True + assert task_time.StatusTime == "2000-01-01T00:00:00" + assert task_time.ActualDuration == "P1D" + assert task_time.ActualStart == "2000-01-01T00:00:00" + assert task_time.ActualFinish == "2000-01-02T00:00:00" + assert task_time.RemainingTime == "P1D" + assert task_time.Completion == 0.5