@@ -60,9 +60,22 @@ def test_create_task_fixed_duration(self) -> None:
60
60
ps .FixedDurationTask ('NegativeWorkAmount' , 2 , work_amount = - 3 )
61
61
62
62
def test_create_task_variable_duration (self ) -> None :
63
- task = ps .VariableDurationTask ('vdt' )
64
- self .assertIsInstance (task , ps .VariableDurationTask )
65
-
63
+ ps .VariableDurationTask ('vdt1' )
64
+ ps .VariableDurationTask ('vdt2' , length_at_most = 4 )
65
+ ps .VariableDurationTask ('vdt3' , length_at_least = 4 )
66
+ ps .VariableDurationTask ('vdt21' , work_amount = 10 )
67
+ with self .assertRaises (TypeError ):
68
+ ps .VariableDurationTask ('vdt3' , length_at_most = 4.5 )
69
+ with self .assertRaises (TypeError ):
70
+ ps .VariableDurationTask ('vdt4' , length_at_most = - 1 )
71
+ with self .assertRaises (TypeError ):
72
+ ps .VariableDurationTask ('vdt5' , length_at_least = - 1 )
73
+ with self .assertRaises (TypeError ):
74
+ ps .VariableDurationTask ('vdt6' , work_amount = - 1 )
75
+ with self .assertRaises (TypeError ):
76
+ ps .VariableDurationTask ('vdt7' , work_amount = 1.5 )
77
+ with self .assertRaises (TypeError ):
78
+ ps .VariableDurationTask ('vdt8' , work_amount = None )
66
79
#
67
80
# Workers
68
81
#
@@ -94,7 +107,7 @@ def test_eq_overloading(self) -> None:
94
107
self .assertEqual (task_1 , task_1 )
95
108
self .assertNotEqual (task_1 , task_2 )
96
109
97
- def test_redondnt_tasks_resources (self ) -> None :
110
+ def test_redondant_tasks_resources (self ) -> None :
98
111
pb = ps .SchedulingProblem ('ProblemRedundantTaskResource' )
99
112
# we should not be able to add twice the same resource or task
100
113
task_1 = ps .ZeroDurationTask ('task1' )
@@ -124,6 +137,18 @@ def test_redondnt_tasks_resources(self) -> None:
124
137
pb .add_resource (2.0 )
125
138
self .assertEqual (list (pb .get_resources ()), [worker_1 ])
126
139
140
+ def test_resource_requirements (self ) -> None :
141
+ task_1 = ps .FixedDurationTask ('task1' , duration = 3 )
142
+ worker_1 = ps .Worker ('Worker1' )
143
+ worker_2 = ps .Worker ('Worker1' )
144
+ worker_3 = ps .Worker ('Worker1' )
145
+ task_1 .add_required_resource (worker_1 )
146
+ task_1 .add_required_resources ([worker_1 , worker_2 ])
147
+ with self .assertRaises (TypeError ):
148
+ task_1 .add_required_resource (3 )
149
+ with self .assertRaises (TypeError ):
150
+ task_1 .add_required_resources ("a_string" )
151
+
127
152
#
128
153
# Single task constraints
129
154
#
0 commit comments