mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 09:48:32 +00:00
Fix bug where zero durations were not allowed in task times.
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import datetime
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
|
||||
@@ -66,3 +67,64 @@ class TestEditTaskTime(test.bootstrap.IFC4):
|
||||
assert task_time.ActualFinish == "2000-01-02T00:00:00"
|
||||
assert task_time.RemainingTime == "P1D"
|
||||
assert task_time.Completion == 0.5
|
||||
|
||||
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("sequence.edit_task_time", self.file, task_time=task_time, attributes={
|
||||
"DurationType": "ELAPSEDTIME",
|
||||
"ScheduleDuration": "P1D",
|
||||
"ScheduleStart": "2000-01-01T00:00:00",
|
||||
})
|
||||
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"
|
||||
|
||||
def test_schedule_durations_are_auto_calculated_if_possible(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={
|
||||
"DurationType": "ELAPSEDTIME",
|
||||
"ScheduleStart": "2000-01-01T00:00:00",
|
||||
"ScheduleFinish": "2000-01-02T00:00:00",
|
||||
})
|
||||
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"
|
||||
|
||||
def test_a_duration_takes_priority_over_start_and_finish_dates(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={
|
||||
"DurationType": "ELAPSEDTIME",
|
||||
"ScheduleDuration": "P1D",
|
||||
"ScheduleStart": "2000-01-01T00:00:00",
|
||||
"ScheduleFinish": "2000-01-03T00:00:00",
|
||||
})
|
||||
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"
|
||||
|
||||
def test_durations_can_be_specified_in_datetime_objects(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={
|
||||
"DurationType": "ELAPSEDTIME",
|
||||
"ScheduleDuration": datetime.timedelta(days=1),
|
||||
"ScheduleStart": "2000-01-01T00:00:00",
|
||||
})
|
||||
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"
|
||||
|
||||
def test_zero_durations_are_allowed(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={
|
||||
"DurationType": "ELAPSEDTIME",
|
||||
"ScheduleDuration": datetime.timedelta(),
|
||||
"ScheduleStart": "2000-01-01T00:00:00",
|
||||
})
|
||||
assert task_time.DurationType == "ELAPSEDTIME"
|
||||
assert task_time.ScheduleDuration == "P0D"
|
||||
assert task_time.ScheduleStart == "2000-01-01T00:00:00"
|
||||
assert task_time.ScheduleFinish == "2000-01-01T00:00:00"
|
||||
|
||||
Reference in New Issue
Block a user