mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-09 13:52:23 +00:00
Minor fix
This commit is contained in:
@@ -44,7 +44,7 @@ class Usecase:
|
|||||||
else:
|
else:
|
||||||
print("... is a predecessor to ...", debug_task)
|
print("... is a predecessor to ...", debug_task)
|
||||||
print("... which is cyclically a predecessor to ...", task)
|
print("... which is cyclically a predecessor to ...", task)
|
||||||
raise Exception("Recursive tasks found. Could not cascade schedule.")
|
raise RecursionError("Recursive tasks found. Could not cascade schedule.")
|
||||||
|
|
||||||
if not task.TaskTime:
|
if not task.TaskTime:
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ class Usecase:
|
|||||||
break # We have an infinite loop due to a cyclic graph
|
break # We have an infinite loop due to a cyclic graph
|
||||||
|
|
||||||
if is_cyclic:
|
if is_cyclic:
|
||||||
raise Exception("Task graph is cyclic and so critical path method cannot be performed.")
|
raise RecursionError("Task graph is cyclic and so critical path method cannot be performed.")
|
||||||
return
|
return
|
||||||
|
|
||||||
self.pending_nodes = set(self.g.nodes)
|
self.pending_nodes = set(self.g.nodes)
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import pytest
|
||||||
import datetime
|
import datetime
|
||||||
import test.bootstrap
|
import test.bootstrap
|
||||||
import ifcopenshell.api
|
import ifcopenshell.api
|
||||||
@@ -53,6 +54,14 @@ class TestCascadeSchedule(test.bootstrap.IFC4):
|
|||||||
assert task3.TaskTime.ScheduleStart == "2000-01-02T09:00:00"
|
assert task3.TaskTime.ScheduleStart == "2000-01-02T09:00:00"
|
||||||
assert task3.TaskTime.ScheduleFinish == "2000-01-04T17:00:00"
|
assert task3.TaskTime.ScheduleFinish == "2000-01-04T17:00:00"
|
||||||
|
|
||||||
|
def test_catching_cyclic_relationships(self):
|
||||||
|
task = self._create_task("P1D")
|
||||||
|
task2 = self._create_task("P2D")
|
||||||
|
self._create_sequence(task, task2, "FINISH_START")
|
||||||
|
with pytest.raises(RecursionError):
|
||||||
|
self._create_sequence(task2, task, "FINISH_START")
|
||||||
|
ifcopenshell.api.run("sequence.cascade_schedule", self.file, task=task)
|
||||||
|
|
||||||
def test_cascading_finish_to_start(self):
|
def test_cascading_finish_to_start(self):
|
||||||
task = self._create_task("P1D")
|
task = self._create_task("P1D")
|
||||||
task2 = self._create_task("P2D")
|
task2 = self._create_task("P2D")
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import pytest
|
||||||
import datetime
|
import datetime
|
||||||
import test.bootstrap
|
import test.bootstrap
|
||||||
import ifcopenshell.api
|
import ifcopenshell.api
|
||||||
@@ -29,6 +30,20 @@ class TestRecalculateSchedule(test.bootstrap.IFC4):
|
|||||||
ifcopenshell.api.run("sequence.recalculate_schedule", self.file, work_schedule=self.work_schedule)
|
ifcopenshell.api.run("sequence.recalculate_schedule", self.file, work_schedule=self.work_schedule)
|
||||||
assert task.TaskTime is None
|
assert task.TaskTime is None
|
||||||
|
|
||||||
|
def test_catching_cyclic_relationships(self):
|
||||||
|
self._add_work_schedule()
|
||||||
|
task = self._create_task("P1D")
|
||||||
|
task2 = self._create_task("P2D")
|
||||||
|
task3 = self._create_task("P2D")
|
||||||
|
task4 = self._create_task("P2D")
|
||||||
|
self._create_sequence(task, task2, "FINISH_START")
|
||||||
|
self._create_sequence(task, task4, "FINISH_START")
|
||||||
|
self._create_sequence(task2, task3, "FINISH_START")
|
||||||
|
with pytest.raises(RecursionError):
|
||||||
|
self._create_sequence(task3, task2, "FINISH_START")
|
||||||
|
with pytest.raises(RecursionError):
|
||||||
|
ifcopenshell.api.run("sequence.recalculate_schedule", self.file, work_schedule=self.work_schedule)
|
||||||
|
|
||||||
def test_recalculating_for_a_single_task(self):
|
def test_recalculating_for_a_single_task(self):
|
||||||
self._add_work_schedule()
|
self._add_work_schedule()
|
||||||
task = self._create_task("P1D")
|
task = self._create_task("P1D")
|
||||||
|
|||||||
Reference in New Issue
Block a user