Blame view

src/scheduler/tests.py 28.7 KB
7a1effdd   haribo   scheduler app cre...
1
from django.test import TestCase
ddf59dd4   haribo   Remaniement :
2
3
from scheduler.Scheduler import Scheduler
from common.models import *
a2283bf3   haribo   Date: 20/05/2016
4
from scheduler.simulator import Simulator
7a1effdd   haribo   scheduler app cre...
5

a2283bf3   haribo   Date: 20/05/2016
6
SIMULATION_FILE = 'file:./scheduler/sequences_cador.html'
b87b6d9b   haribo   Finished tests fo...
7

bca9a283   Jeremy   Reworked the sche...
8

b87b6d9b   haribo   Finished tests fo...
9
class SchedulerTest(TestCase):
94336356   haribo   Added starting fi...
10

05bdcc44   Etienne Pallier   BIG DEMO tests (s...
11
    # (EP) Create a fixture in memory with 1 scheduler, 3 requests belonging to 3 different users
b87b6d9b   haribo   Finished tests fo...
12
13
14
15
16
17
    def setUp(self):
        '''
            Creates the scheduler
            Creates 3 users (and associated needs)
            Creates 3 requests

94082e77   haribo   Date: 03/06/2016
18
            Creates associated needs : scientific program, country, user_level
b87b6d9b   haribo   Finished tests fo...
19
        '''
94336356   haribo   Added starting fi...
20

b87b6d9b   haribo   Finished tests fo...
21
        self.scheduler = Scheduler()
94336356   haribo   Added starting fi...
22

7a79e25b   haribo   Date: 19/05/2016
23
24
        self.scheduler.max_overhead = 1

b87b6d9b   haribo   Finished tests fo...
25
26
        scipro = ScientificProgram.objects.create()
        country = Country.objects.create()
94082e77   haribo   Date: 03/06/2016
27
        user_level = UserLevel.objects.create()
94336356   haribo   Added starting fi...
28

53787d30   Jeremy   Alert now inherit...
29
30
31
        self.usr1 = PyrosUser.objects.create(username="toto", country=country, user_level=user_level, quota=100)
        self.usr2 = PyrosUser.objects.create(username="titi", country=country, user_level=user_level, quota=100)
        self.usr3 = PyrosUser.objects.create(username="tata", country=country, user_level=user_level, quota=100)
94336356   haribo   Added starting fi...
32

ee2c4543   Etienne Pallier   Bugfix Monitoring...
33
34
35
        self.req1 = Request.objects.create(pyros_user=self.usr1, scientific_program=scipro)
        self.req2 = Request.objects.create(pyros_user=self.usr2, scientific_program=scipro)
        self.req3 = Request.objects.create(pyros_user=self.usr3, scientific_program=scipro)
94336356   haribo   Added starting fi...
36

b87b6d9b   haribo   Finished tests fo...
37
38
39
40
41
    def test_basic_3_seq(self):
        '''
            goal : test if 3 distinct sequences are put into the planning
            conditions : the sequence have the same priority, and have no jd overlap
        '''
94336356   haribo   Added starting fi...
42

b87b6d9b   haribo   Finished tests fo...
43
        print("\n===== TEST_BASIC_3_SEQ =====\n")
94336356   haribo   Added starting fi...
44

b87b6d9b   haribo   Finished tests fo...
45
46
47
48
        self.scheduler.schedule.plan_start = 0
        self.scheduler.schedule.plan_end = 10

        ''' create the sequences '''
4b503f5c   jeremy   Update installer ...
49
        seq1 = Sequence.objects.create(request=self.req1, status=Sequence.TOBEPLANNED,
94336356   haribo   Added starting fi...
50
                                       name="seq1", jd1=0, jd2=2, priority=1, t_prefered=-1, duration=1)
4b503f5c   jeremy   Update installer ...
51
        seq2 = Sequence.objects.create(request=self.req1, status=Sequence.TOBEPLANNED,
94336356   haribo   Added starting fi...
52
                                       name="seq2", jd1=4, jd2=6, priority=1, t_prefered=-1, duration=1)
4b503f5c   jeremy   Update installer ...
53
        seq3 = Sequence.objects.create(request=self.req1, status=Sequence.TOBEPLANNED,
94336356   haribo   Added starting fi...
54
55
                                       name="seq3", jd1=7, jd2=9, priority=1, t_prefered=-1, duration=1)

b87b6d9b   haribo   Finished tests fo...
56
        ''' compute and print the schedule '''
bca9a283   Jeremy   Reworked the sche...
57
        self.scheduler.makeSchedule()
94336356   haribo   Added starting fi...
58

7a79e25b   haribo   Date: 19/05/2016
59
60
        sched = Schedule.objects.order_by('-created')[0]
        shs_list = sched.shs.all()
4b503f5c   jeremy   Update installer ...
61
        nbPlanned = len([shs for shs in shs_list if shs.status == Sequence.PLANNED])
94336356   haribo   Added starting fi...
62

bca9a283   Jeremy   Reworked the sche...
63
64
        self.assertEqual(nbPlanned, 3)

7a79e25b   haribo   Date: 19/05/2016
65
66
67
        shs1 = next(shs for shs in shs_list if shs.sequence == seq1)
        shs2 = next(shs for shs in shs_list if shs.sequence == seq2)
        shs3 = next(shs for shs in shs_list if shs.sequence == seq3)
b87b6d9b   haribo   Finished tests fo...
68
69

        ''' checks tsp, tep, deltaTL and deltaTR for every sequence '''
94336356   haribo   Added starting fi...
70

7a79e25b   haribo   Date: 19/05/2016
71
72
73
74
        self.assertEqual(shs1.tsp, 1)
        self.assertEqual(shs1.tep, 2)
        self.assertEqual(shs1.deltaTL, 0)
        self.assertEqual(shs1.deltaTR, 0)
94336356   haribo   Added starting fi...
75

7a79e25b   haribo   Date: 19/05/2016
76
77
78
79
        self.assertEqual(shs2.tsp, 4)
        self.assertEqual(shs2.tep, 5)
        self.assertEqual(shs2.deltaTL, 0)
        self.assertEqual(shs2.deltaTR, 1)
b87b6d9b   haribo   Finished tests fo...
80

7a79e25b   haribo   Date: 19/05/2016
81
82
83
84
        self.assertEqual(shs3.tsp, 7)
        self.assertEqual(shs3.tep, 8)
        self.assertEqual(shs3.deltaTL, 0)
        self.assertEqual(shs3.deltaTR, 1)
b87b6d9b   haribo   Finished tests fo...
85

b87b6d9b   haribo   Finished tests fo...
86
87
88
89
90
    def test_3_seq_with_quotas(self):
        '''
            goal : test if the quotas are decreased
            conditions : the sequences have the same priority, and various durations
        '''
94336356   haribo   Added starting fi...
91

b87b6d9b   haribo   Finished tests fo...
92
93
94
95
96
        print("\n===== TEST_3_SEQ_WITH_QUOTAS =====\n")

        self.scheduler.schedule.plan_start = 0
        self.scheduler.schedule.plan_end = 100

b87b6d9b   haribo   Finished tests fo...
97
        ''' create the sequences '''
4b503f5c   jeremy   Update installer ...
98
        seq1 = Sequence.objects.create(request=self.req1, status=Sequence.TOBEPLANNED,
7a79e25b   haribo   Date: 19/05/2016
99
                                       name="seq1", jd1=1, jd2=30, priority=1, t_prefered=-1, duration=3)
4b503f5c   jeremy   Update installer ...
100
        seq2 = Sequence.objects.create(request=self.req2, status=Sequence.TOBEPLANNED,
7a79e25b   haribo   Date: 19/05/2016
101
                                       name="seq2", jd1=1, jd2=30, priority=1, t_prefered=-1, duration=10)
4b503f5c   jeremy   Update installer ...
102
        seq3 = Sequence.objects.create(request=self.req3, status=Sequence.TOBEPLANNED,
7a79e25b   haribo   Date: 19/05/2016
103
                                       name="seq3", jd1=1, jd2=30, priority=1, t_prefered=-1, duration=5)
94336356   haribo   Added starting fi...
104

b87b6d9b   haribo   Finished tests fo...
105
106
107
108
109
110
111
112
        seq1.request.pyros_user.quota = 100
        seq1.request.pyros_user.save()
        seq2.request.pyros_user.quota = 100
        seq2.request.pyros_user.save()
        seq3.request.pyros_user.quota = 100
        seq3.request.pyros_user.save()

        ''' compute and print the schedule '''
bca9a283   Jeremy   Reworked the sche...
113
        self.scheduler.makeSchedule()
94336356   haribo   Added starting fi...
114

7a79e25b   haribo   Date: 19/05/2016
115
116
        sched = Schedule.objects.order_by('-created')[0]
        shs_list = sched.shs.all()
4b503f5c   jeremy   Update installer ...
117
        nbPlanned = len([shs for shs in shs_list if shs.status == Sequence.PLANNED])
b87b6d9b   haribo   Finished tests fo...
118
119
120
121
122
123

        seq1 = Sequence.objects.get(name="seq1")
        seq2 = Sequence.objects.get(name="seq2")
        seq3 = Sequence.objects.get(name="seq3")

        ''' checks sequence owners' quotas '''
94336356   haribo   Added starting fi...
124

b87b6d9b   haribo   Finished tests fo...
125
126
127
128
129
130
131
132
133
134
135
        self.assertEqual(nbPlanned, 3)

        self.assertEqual(seq1.request.pyros_user.quota, 100 - 3)
        self.assertEqual(seq2.request.pyros_user.quota, 100 - 10)
        self.assertEqual(seq3.request.pyros_user.quota, 100 - 5)

    def test_4_seq_insufficient_quotas(self):
        '''
            goal : test if an insufficient quota blocks sequence programmation
            conditions : the sequences have the same priority, a user has 2 sequence, the others have 1 Sequence
        '''
94336356   haribo   Added starting fi...
136

b87b6d9b   haribo   Finished tests fo...
137
138
139
140
141
        print("\n===== TEST_4_SEQ_INSUFFICIENT_QUOTAS =====\n")

        self.scheduler.schedule.plan_start = 0
        self.scheduler.schedule.plan_end = 100

b87b6d9b   haribo   Finished tests fo...
142
        ''' create the sequences '''
4b503f5c   jeremy   Update installer ...
143
        seq1 = Sequence.objects.create(request=self.req1, status=Sequence.TOBEPLANNED,
94336356   haribo   Added starting fi...
144
                                       name="seq1", jd1=1, jd2=200, priority=1, t_prefered=-1, duration=3)
4b503f5c   jeremy   Update installer ...
145
        seq2 = Sequence.objects.create(request=self.req1, status=Sequence.TOBEPLANNED,
94336356   haribo   Added starting fi...
146
                                       name="seq2", jd1=1, jd2=200, priority=1, t_prefered=-1, duration=10)
4b503f5c   jeremy   Update installer ...
147
        seq3 = Sequence.objects.create(request=self.req2, status=Sequence.TOBEPLANNED,
94336356   haribo   Added starting fi...
148
                                       name="seq3", jd1=1, jd2=200, priority=1, t_prefered=-1, duration=10)
4b503f5c   jeremy   Update installer ...
149
        seq4 = Sequence.objects.create(request=self.req3, status=Sequence.TOBEPLANNED,
94336356   haribo   Added starting fi...
150
151
                                       name="seq4", jd1=1, jd2=200, priority=1, t_prefered=-1, duration=15)

b87b6d9b   haribo   Finished tests fo...
152
153
154
155
156
157
158
159
        seq1.request.pyros_user.quota = 11
        seq1.request.pyros_user.save()
        seq3.request.pyros_user.quota = 10
        seq3.request.pyros_user.save()
        seq4.request.pyros_user.quota = 14
        seq4.request.pyros_user.save()

        ''' compute and print the schedule '''
bca9a283   Jeremy   Reworked the sche...
160
        self.scheduler.makeSchedule()
94336356   haribo   Added starting fi...
161

7a79e25b   haribo   Date: 19/05/2016
162
163
        sched = Schedule.objects.order_by('-created')[0]
        shs_list = sched.shs.all()
4b503f5c   jeremy   Update installer ...
164
        nbPlanned = len([shs for shs in shs_list if shs.status == Sequence.PLANNED])
b87b6d9b   haribo   Finished tests fo...
165
166
167
168
169
170
171

        seq1 = Sequence.objects.get(name="seq1")
        seq2 = Sequence.objects.get(name="seq2")
        seq3 = Sequence.objects.get(name="seq3")
        seq4 = Sequence.objects.get(name="seq4")

        ''' checks sequence owners' quotas '''
94336356   haribo   Added starting fi...
172

b87b6d9b   haribo   Finished tests fo...
173
174
175
176
177
178
179
180
181
182
183
        self.assertEqual(nbPlanned, 2)

        self.assertEqual(seq1.request.pyros_user.quota, 11 - 3 - 0)
        self.assertEqual(seq3.request.pyros_user.quota, 10 - 10)
        self.assertEqual(seq4.request.pyros_user.quota, 14 - 0)

    def test_3_seq_priority(self):
        '''
            goal : test if the priority is taken into account when there isn't enough room
            conditions : sequences have different priorities, are visible the whole night and can't be all put
        '''
94336356   haribo   Added starting fi...
184

b87b6d9b   haribo   Finished tests fo...
185
186
187
188
189
        print("\n===== TEST_3_SEQ_PRIORITY =====\n")

        self.scheduler.schedule.plan_start = 0
        self.scheduler.schedule.plan_end = 20

b87b6d9b   haribo   Finished tests fo...
190
        ''' create the sequences '''
4b503f5c   jeremy   Update installer ...
191
        seq1 = Sequence.objects.create(request=self.req1, status=Sequence.TOBEPLANNED,
94336356   haribo   Added starting fi...
192
                                       name="seq1", jd1=1, jd2=200, priority=10, t_prefered=-1, duration=10)
4b503f5c   jeremy   Update installer ...
193
        seq2 = Sequence.objects.create(request=self.req2, status=Sequence.TOBEPLANNED,
94336356   haribo   Added starting fi...
194
                                       name="seq2", jd1=1, jd2=200, priority=9, t_prefered=-1, duration=11)
4b503f5c   jeremy   Update installer ...
195
        seq3 = Sequence.objects.create(request=self.req3, status=Sequence.TOBEPLANNED,
94336356   haribo   Added starting fi...
196
                                       name="seq3", jd1=1, jd2=200, priority=11, t_prefered=-1, duration=10)
b87b6d9b   haribo   Finished tests fo...
197
198

        ''' compute and print the schedule '''
bca9a283   Jeremy   Reworked the sche...
199
        self.scheduler.makeSchedule()
94336356   haribo   Added starting fi...
200

7a79e25b   haribo   Date: 19/05/2016
201
202
        sched = Schedule.objects.order_by('-created')[0]
        shs_list = sched.shs.all()
4b503f5c   jeremy   Update installer ...
203
        nbPlanned = len([shs for shs in shs_list if shs.status == Sequence.PLANNED])
b87b6d9b   haribo   Finished tests fo...
204

7a79e25b   haribo   Date: 19/05/2016
205
        shs2 = next(shs for shs in shs_list if shs.sequence == seq2)
b87b6d9b   haribo   Finished tests fo...
206
207

        ''' checks which sequence is planned '''
94336356   haribo   Added starting fi...
208

b87b6d9b   haribo   Finished tests fo...
209
210
        self.assertEqual(nbPlanned, 1)

4b503f5c   jeremy   Update installer ...
211
        self.assertEqual(shs2.status, Sequence.PLANNED)
b87b6d9b   haribo   Finished tests fo...
212

b87b6d9b   haribo   Finished tests fo...
213
214
215
216
217
    def test_3_seq_priority_overlap(self):
        '''
            goal : test if the sequences are arranged according to the priorities
            conditions : sequences have different priorities, are visible the whole night and can be all put (enough room)
        '''
94336356   haribo   Added starting fi...
218

b87b6d9b   haribo   Finished tests fo...
219
220
221
222
223
        print("\n===== TEST_3_SEQ_PRIORITY_OVERLAP =====\n")

        self.scheduler.schedule.plan_start = 0
        self.scheduler.schedule.plan_end = 200

b87b6d9b   haribo   Finished tests fo...
224
        ''' create the sequences '''
4b503f5c   jeremy   Update installer ...
225
        seq1 = Sequence.objects.create(request=self.req1, status=Sequence.TOBEPLANNED,
94336356   haribo   Added starting fi...
226
                                       name="seq1", jd1=1, jd2=200, priority=10, t_prefered=-1, duration=10)
4b503f5c   jeremy   Update installer ...
227
        seq2 = Sequence.objects.create(request=self.req2, status=Sequence.TOBEPLANNED,
94336356   haribo   Added starting fi...
228
                                       name="seq2", jd1=1, jd2=200, priority=9, t_prefered=-1, duration=11)
4b503f5c   jeremy   Update installer ...
229
        seq3 = Sequence.objects.create(request=self.req3, status=Sequence.TOBEPLANNED,
94336356   haribo   Added starting fi...
230
                                       name="seq3", jd1=1, jd2=200, priority=11, t_prefered=-1, duration=12)
b87b6d9b   haribo   Finished tests fo...
231
232

        ''' compute and print the schedule '''
bca9a283   Jeremy   Reworked the sche...
233
        self.scheduler.makeSchedule()
94336356   haribo   Added starting fi...
234

7a79e25b   haribo   Date: 19/05/2016
235
236
        sched = Schedule.objects.order_by('-created')[0]
        shs_list = sched.shs.all()
4b503f5c   jeremy   Update installer ...
237
        nbPlanned = len([shs for shs in shs_list if shs.status == Sequence.PLANNED])
b87b6d9b   haribo   Finished tests fo...
238

7a79e25b   haribo   Date: 19/05/2016
239
240
241
        shs1 = next(shs for shs in shs_list if shs.sequence == seq1)
        shs2 = next(shs for shs in shs_list if shs.sequence == seq2)
        shs3 = next(shs for shs in shs_list if shs.sequence == seq3)
b87b6d9b   haribo   Finished tests fo...
242
243

        ''' checks tsp, tep, deltaTL and deltaTR for every sequence '''
94336356   haribo   Added starting fi...
244

b87b6d9b   haribo   Finished tests fo...
245
246
        self.assertEqual(nbPlanned, 3)

7a79e25b   haribo   Date: 19/05/2016
247
248
249
250
        self.assertEqual(shs2.tsp, 1)
        self.assertEqual(shs2.tep, 12)
        self.assertEqual(shs2.deltaTL, 0)
        self.assertEqual(shs2.deltaTR, 0)
94336356   haribo   Added starting fi...
251

7a79e25b   haribo   Date: 19/05/2016
252
253
254
255
        self.assertEqual(shs1.tsp, 13)
        self.assertEqual(shs1.tep, 23)
        self.assertEqual(shs1.deltaTL, 0)
        self.assertEqual(shs1.deltaTR, 0)
b87b6d9b   haribo   Finished tests fo...
256

7a79e25b   haribo   Date: 19/05/2016
257
258
259
260
        self.assertEqual(shs3.tsp, 24)
        self.assertEqual(shs3.tep, 36)
        self.assertEqual(shs3.deltaTL, 0)
        self.assertEqual(shs3.deltaTR, 200 - shs3.tep)
b87b6d9b   haribo   Finished tests fo...
261
262
263
264
265
266

    def test_3_seq_t_prefered(self):
        '''
            goal: test if the sequences are wall_arranged with t_prefered
            conditions : various t_prefered that should put the sequences at the beginning, the middle and the end of the night
        '''
94336356   haribo   Added starting fi...
267

b87b6d9b   haribo   Finished tests fo...
268
269
270
271
272
        print("\n===== TEST_3_SEQ_T_PREFERED =====\n")

        self.scheduler.schedule.plan_start = 0
        self.scheduler.schedule.plan_end = 200

b87b6d9b   haribo   Finished tests fo...
273
        ''' create the sequences '''
4b503f5c   jeremy   Update installer ...
274
        seq1 = Sequence.objects.create(request=self.req1, status=Sequence.TOBEPLANNED,
94336356   haribo   Added starting fi...
275
                                       name="seq1", jd1=0, jd2=200, priority=1, t_prefered=11, duration=20)
4b503f5c   jeremy   Update installer ...
276
        seq2 = Sequence.objects.create(request=self.req2, status=Sequence.TOBEPLANNED,
94336356   haribo   Added starting fi...
277
                                       name="seq2", jd1=0, jd2=200, priority=1, t_prefered=100, duration=20)
4b503f5c   jeremy   Update installer ...
278
        seq3 = Sequence.objects.create(request=self.req3, status=Sequence.TOBEPLANNED,
94336356   haribo   Added starting fi...
279
                                       name="seq3", jd1=0, jd2=200, priority=1, t_prefered=191, duration=20)
b87b6d9b   haribo   Finished tests fo...
280
281

        ''' compute and print the schedule '''
bca9a283   Jeremy   Reworked the sche...
282
        self.scheduler.makeSchedule()
94336356   haribo   Added starting fi...
283

7a79e25b   haribo   Date: 19/05/2016
284
285
        sched = Schedule.objects.order_by('-created')[0]
        shs_list = sched.shs.all()
4b503f5c   jeremy   Update installer ...
286
        nbPlanned = len([shs for shs in shs_list if shs.status == Sequence.PLANNED])
b87b6d9b   haribo   Finished tests fo...
287

bca9a283   Jeremy   Reworked the sche...
288
289
        self.assertEqual(nbPlanned, 3)

7a79e25b   haribo   Date: 19/05/2016
290
291
292
        shs1 = next(shs for shs in shs_list if shs.sequence == seq1)
        shs2 = next(shs for shs in shs_list if shs.sequence == seq2)
        shs3 = next(shs for shs in shs_list if shs.sequence == seq3)
b87b6d9b   haribo   Finished tests fo...
293
294

        ''' checks tsp, tep, deltaTL and deltaTR for every sequence '''
94336356   haribo   Added starting fi...
295

bca9a283   Jeremy   Reworked the sche...
296
        self.scheduler.logSchedule()
b87b6d9b   haribo   Finished tests fo...
297

7a79e25b   haribo   Date: 19/05/2016
298
299
300
301
        self.assertEqual(shs1.tsp, 1)
        self.assertEqual(shs1.tep, 21)
        self.assertEqual(shs1.deltaTL, 0)
        self.assertEqual(shs1.deltaTR, shs2.tsp - 1 - shs1.tep)
94336356   haribo   Added starting fi...
302

7a79e25b   haribo   Date: 19/05/2016
303
304
305
306
        self.assertEqual(shs2.tsp, 90)
        self.assertEqual(shs2.tep, 110)
        self.assertEqual(shs2.deltaTL, shs1.deltaTR)
        self.assertEqual(shs2.deltaTR, shs3.tsp - 1 - shs2.tep)
b87b6d9b   haribo   Finished tests fo...
307

7a79e25b   haribo   Date: 19/05/2016
308
309
310
311
        self.assertEqual(shs3.tsp, 180)
        self.assertEqual(shs3.tep, 200)
        self.assertEqual(shs3.deltaTL, shs2.deltaTR)
        self.assertEqual(shs3.deltaTR, 0)
b87b6d9b   haribo   Finished tests fo...
312
313
314
315
316
317

    def test_3_seq_t_prefered_priority(self):
        '''
            goal: test if the sequences are wall_arranged with t_prefered and priority
            conditions : various t_prefered that should put the sequences the middle of the night, according to priority
        '''
94336356   haribo   Added starting fi...
318

b87b6d9b   haribo   Finished tests fo...
319
320
321
322
323
        print("\n===== TEST_3_SEQ_T_PREFERED_PRIORITY =====\n")

        self.scheduler.schedule.plan_start = 0
        self.scheduler.schedule.plan_end = 200

b87b6d9b   haribo   Finished tests fo...
324
        ''' create the sequences '''
4b503f5c   jeremy   Update installer ...
325
        seq1 = Sequence.objects.create(request=self.req1, status=Sequence.TOBEPLANNED,
94336356   haribo   Added starting fi...
326
                                       name="seq1", jd1=0, jd2=200, priority=1, t_prefered=100, duration=20)
4b503f5c   jeremy   Update installer ...
327
        seq2 = Sequence.objects.create(request=self.req2, status=Sequence.TOBEPLANNED,
94336356   haribo   Added starting fi...
328
                                       name="seq2", jd1=0, jd2=200, priority=0, t_prefered=100, duration=20)
4b503f5c   jeremy   Update installer ...
329
        seq3 = Sequence.objects.create(request=self.req3, status=Sequence.TOBEPLANNED,
94336356   haribo   Added starting fi...
330
                                       name="seq3", jd1=0, jd2=200, priority=2, t_prefered=100, duration=20)
b87b6d9b   haribo   Finished tests fo...
331
332

        ''' compute and print the schedule '''
bca9a283   Jeremy   Reworked the sche...
333
        self.scheduler.makeSchedule()
94336356   haribo   Added starting fi...
334

7a79e25b   haribo   Date: 19/05/2016
335
336
        sched = Schedule.objects.order_by('-created')[0]
        shs_list = sched.shs.all()
4b503f5c   jeremy   Update installer ...
337
        nbPlanned = len([shs for shs in shs_list if shs.status == Sequence.PLANNED])
b87b6d9b   haribo   Finished tests fo...
338

bca9a283   Jeremy   Reworked the sche...
339
340
        self.assertEqual(nbPlanned, 3)

7a79e25b   haribo   Date: 19/05/2016
341
342
343
        shs1 = next(shs for shs in shs_list if shs.sequence == seq1)
        shs2 = next(shs for shs in shs_list if shs.sequence == seq2)
        shs3 = next(shs for shs in shs_list if shs.sequence == seq3)
b87b6d9b   haribo   Finished tests fo...
344
345

        ''' checks tsp, tep, deltaTL and deltaTR for every sequence '''
94336356   haribo   Added starting fi...
346

b87b6d9b   haribo   Finished tests fo...
347

7a79e25b   haribo   Date: 19/05/2016
348
349
        self.assertEqual(shs1.tsp, 69)
        self.assertEqual(shs1.tep, 89)
92039557   haribo   Minor fix : t_pre...
350
        self.assertEqual(shs1.deltaTL, 68)
7a79e25b   haribo   Date: 19/05/2016
351
        self.assertEqual(shs1.deltaTR, 0)
94336356   haribo   Added starting fi...
352

7a79e25b   haribo   Date: 19/05/2016
353
354
355
        self.assertEqual(shs2.tsp, 90)
        self.assertEqual(shs2.tep, 110)
        self.assertEqual(shs2.deltaTL, 0)
92039557   haribo   Minor fix : t_pre...
356
        self.assertEqual(shs2.deltaTR, 0)
b87b6d9b   haribo   Finished tests fo...
357

92039557   haribo   Minor fix : t_pre...
358
359
360
361
        self.assertEqual(shs3.tsp, 111)
        self.assertEqual(shs3.tep, 131)
        self.assertEqual(shs3.deltaTL, 0)
        self.assertEqual(shs3.deltaTR, 200 - shs3.tep)
b87b6d9b   haribo   Finished tests fo...
362
363
364
365
366

    def test_3_seq_move_left(self):
        '''
            goal: test if a sequence can move to the left to let another one
            conditions : use priorities to place 2 sequences with an interval between, then try to put a bigger sequence in it
94336356   haribo   Added starting fi...
367
368
        '''

b87b6d9b   haribo   Finished tests fo...
369
370
371
        print("\n===== TEST_3_SEQ_MOVE_LEFT =====\n")

        self.scheduler.schedule.plan_start = 0
7a79e25b   haribo   Date: 19/05/2016
372
        self.scheduler.schedule.plan_end = 58
b87b6d9b   haribo   Finished tests fo...
373

b87b6d9b   haribo   Finished tests fo...
374
        ''' create the sequences '''
4b503f5c   jeremy   Update installer ...
375
        seq1 = Sequence.objects.create(request=self.req1, status=Sequence.TOBEPLANNED,
94336356   haribo   Added starting fi...
376
                                       name="seq1", jd1=0, jd2=200, priority=1, t_prefered=15, duration=20)
4b503f5c   jeremy   Update installer ...
377
        seq2 = Sequence.objects.create(request=self.req2, status=Sequence.TOBEPLANNED,
94336356   haribo   Added starting fi...
378
                                       name="seq2", jd1=0, jd2=200, priority=1, t_prefered=45, duration=20)
4b503f5c   jeremy   Update installer ...
379
        seq3 = Sequence.objects.create(request=self.req3, status=Sequence.TOBEPLANNED,
94336356   haribo   Added starting fi...
380
                                       name="seq3", jd1=0, jd2=200, priority=2, t_prefered=30, duration=15)
b87b6d9b   haribo   Finished tests fo...
381
382

        ''' compute and print the schedule '''
bca9a283   Jeremy   Reworked the sche...
383
        self.scheduler.makeSchedule()
94336356   haribo   Added starting fi...
384

7a79e25b   haribo   Date: 19/05/2016
385
386
        sched = Schedule.objects.order_by('-created')[0]
        shs_list = sched.shs.all()
4b503f5c   jeremy   Update installer ...
387
        nbPlanned = len([shs for shs in shs_list if shs.status == Sequence.PLANNED])
b87b6d9b   haribo   Finished tests fo...
388

bca9a283   Jeremy   Reworked the sche...
389
390
        self.assertEqual(nbPlanned, 3)

7a79e25b   haribo   Date: 19/05/2016
391
392
393
        shs1 = next(shs for shs in shs_list if shs.sequence == seq1)
        shs2 = next(shs for shs in shs_list if shs.sequence == seq2)
        shs3 = next(shs for shs in shs_list if shs.sequence == seq3)
b87b6d9b   haribo   Finished tests fo...
394
395

        ''' checks tsp, tep, deltaTL and deltaTR for every sequence '''
94336356   haribo   Added starting fi...
396

7a79e25b   haribo   Date: 19/05/2016
397
398
399
400
        self.assertEqual(shs1.tsp, 1)
        self.assertEqual(shs1.tep, 21)
        self.assertEqual(shs1.deltaTL, 0)
        self.assertEqual(shs1.deltaTR, 0)
94336356   haribo   Added starting fi...
401

7a79e25b   haribo   Date: 19/05/2016
402
403
404
405
        self.assertEqual(shs2.tsp, 38)
        self.assertEqual(shs2.tep, 58)
        self.assertEqual(shs2.deltaTL, 0)
        self.assertEqual(shs2.deltaTR, 0)
b87b6d9b   haribo   Finished tests fo...
406

7a79e25b   haribo   Date: 19/05/2016
407
408
409
410
        self.assertEqual(shs3.tsp, 22)
        self.assertEqual(shs3.tep, 37)
        self.assertEqual(shs3.deltaTL, 0)
        self.assertEqual(shs3.deltaTR, 0)
b87b6d9b   haribo   Finished tests fo...
411
412
413
414
415

    def test_3_seq_move_right(self):
        '''
            goal: test if a sequence can move to the right to let another one
            conditions : use priorities to place 2 sequences with an interval between, then try to put a bigger sequence in it
94336356   haribo   Added starting fi...
416
417
        '''

b87b6d9b   haribo   Finished tests fo...
418
419
420
        print("\n===== TEST_3_SEQ_MOVE_RIGHT =====\n")

        self.scheduler.schedule.plan_start = 0
7a79e25b   haribo   Date: 19/05/2016
421
        self.scheduler.schedule.plan_end = 67
b87b6d9b   haribo   Finished tests fo...
422

b87b6d9b   haribo   Finished tests fo...
423
        ''' create the sequences '''
4b503f5c   jeremy   Update installer ...
424
        seq1 = Sequence.objects.create(request=self.req1, status=Sequence.TOBEPLANNED,
94336356   haribo   Added starting fi...
425
                                       name="seq1", jd1=0, jd2=200, priority=1, t_prefered=15, duration=20)
4b503f5c   jeremy   Update installer ...
426
        seq2 = Sequence.objects.create(request=self.req2, status=Sequence.TOBEPLANNED,
7a79e25b   haribo   Date: 19/05/2016
427
                                       name="seq2", jd1=0, jd2=200, priority=1, t_prefered=47, duration=20)
4b503f5c   jeremy   Update installer ...
428
        seq3 = Sequence.objects.create(request=self.req3, status=Sequence.TOBEPLANNED,
94336356   haribo   Added starting fi...
429
                                       name="seq3", jd1=0, jd2=200, priority=2, t_prefered=30, duration=20)
b87b6d9b   haribo   Finished tests fo...
430
431

        ''' compute and print the schedule '''
bca9a283   Jeremy   Reworked the sche...
432
        self.scheduler.makeSchedule()
94336356   haribo   Added starting fi...
433

7a79e25b   haribo   Date: 19/05/2016
434
435
        sched = Schedule.objects.order_by('-created')[0]
        shs_list = sched.shs.all()
4b503f5c   jeremy   Update installer ...
436
        nbPlanned = len([shs for shs in shs_list if shs.status == Sequence.PLANNED])
b87b6d9b   haribo   Finished tests fo...
437

bca9a283   Jeremy   Reworked the sche...
438
439
        self.assertEqual(nbPlanned, 3)

7a79e25b   haribo   Date: 19/05/2016
440
441
442
        shs1 = next(shs for shs in shs_list if shs.sequence == seq1)
        shs2 = next(shs for shs in shs_list if shs.sequence == seq2)
        shs3 = next(shs for shs in shs_list if shs.sequence == seq3)
b87b6d9b   haribo   Finished tests fo...
443
444

        ''' checks tsp, tep, deltaTL and deltaTR for every sequence '''
94336356   haribo   Added starting fi...
445

b87b6d9b   haribo   Finished tests fo...
446

7a79e25b   haribo   Date: 19/05/2016
447
448
449
450
        self.assertEqual(shs1.tsp, 5)
        self.assertEqual(shs1.tep, 25)
        self.assertEqual(shs1.deltaTL, 4)
        self.assertEqual(shs1.deltaTR, 0)
94336356   haribo   Added starting fi...
451

7a79e25b   haribo   Date: 19/05/2016
452
453
454
455
        self.assertEqual(shs2.tsp, 47)
        self.assertEqual(shs2.tep, 67)
        self.assertEqual(shs2.deltaTL, 0)
        self.assertEqual(shs2.deltaTR, 0)
b87b6d9b   haribo   Finished tests fo...
456

7a79e25b   haribo   Date: 19/05/2016
457
458
459
460
        self.assertEqual(shs3.tsp, 26)
        self.assertEqual(shs3.tep, 46)
        self.assertEqual(shs3.deltaTL, 0)
        self.assertEqual(shs3.deltaTR, 0)
b87b6d9b   haribo   Finished tests fo...
461

b87b6d9b   haribo   Finished tests fo...
462
463
464
465
    def test_3_seq_move_both(self):
        '''
            goal: test if a sequence can move to the let AND the right to let another one
            conditions : use priorities to place 2 sequences with an interval between, then try to put a bigger sequence in it
94336356   haribo   Added starting fi...
466
467
        '''

b87b6d9b   haribo   Finished tests fo...
468
469
470
        print("\n===== TEST_3_SEQ_MOVE_BOTH =====\n")

        self.scheduler.schedule.plan_start = 0
7a79e25b   haribo   Date: 19/05/2016
471
        self.scheduler.schedule.plan_end = 68
b87b6d9b   haribo   Finished tests fo...
472

b87b6d9b   haribo   Finished tests fo...
473
        ''' create the sequences '''
4b503f5c   jeremy   Update installer ...
474
        seq1 = Sequence.objects.create(request=self.req1, status=Sequence.TOBEPLANNED,
94336356   haribo   Added starting fi...
475
                                       name="seq1", jd1=0, jd2=200, priority=1, t_prefered=15, duration=20)
4b503f5c   jeremy   Update installer ...
476
        seq2 = Sequence.objects.create(request=self.req2, status=Sequence.TOBEPLANNED,
94336356   haribo   Added starting fi...
477
                                       name="seq2", jd1=0, jd2=200, priority=1, t_prefered=45, duration=20)
4b503f5c   jeremy   Update installer ...
478
        seq3 = Sequence.objects.create(request=self.req3, status=Sequence.TOBEPLANNED,
94336356   haribo   Added starting fi...
479
                                       name="seq3", jd1=0, jd2=200, priority=2, t_prefered=30, duration=25)
b87b6d9b   haribo   Finished tests fo...
480
481

        ''' compute and print the schedule '''
bca9a283   Jeremy   Reworked the sche...
482
        self.scheduler.makeSchedule()
94336356   haribo   Added starting fi...
483

7a79e25b   haribo   Date: 19/05/2016
484
485
        sched = Schedule.objects.order_by('-created')[0]
        shs_list = sched.shs.all()
4b503f5c   jeremy   Update installer ...
486
        nbPlanned = len([shs for shs in shs_list if shs.status == Sequence.PLANNED])
b87b6d9b   haribo   Finished tests fo...
487

bca9a283   Jeremy   Reworked the sche...
488
489
        self.assertEqual(nbPlanned, 3)

7a79e25b   haribo   Date: 19/05/2016
490
491
492
        shs1 = next(shs for shs in shs_list if shs.sequence == seq1)
        shs2 = next(shs for shs in shs_list if shs.sequence == seq2)
        shs3 = next(shs for shs in shs_list if shs.sequence == seq3)
b87b6d9b   haribo   Finished tests fo...
493
494

        ''' checks tsp, tep, deltaTL and deltaTR for every sequence '''
94336356   haribo   Added starting fi...
495

7a79e25b   haribo   Date: 19/05/2016
496
497
498
499
        self.assertEqual(shs1.tsp, 1)
        self.assertEqual(shs1.tep, 21)
        self.assertEqual(shs1.deltaTL, 0)
        self.assertEqual(shs1.deltaTR, 0)
94336356   haribo   Added starting fi...
500

7a79e25b   haribo   Date: 19/05/2016
501
502
503
504
        self.assertEqual(shs2.tsp, 48)
        self.assertEqual(shs2.tep, 68)
        self.assertEqual(shs2.deltaTL, 0)
        self.assertEqual(shs2.deltaTR, 0)
b87b6d9b   haribo   Finished tests fo...
505

7a79e25b   haribo   Date: 19/05/2016
506
507
508
509
        self.assertEqual(shs3.tsp, 22)
        self.assertEqual(shs3.tep, 47)
        self.assertEqual(shs3.deltaTL, 0)
        self.assertEqual(shs3.deltaTR, 0)
b87b6d9b   haribo   Finished tests fo...
510

b87b6d9b   haribo   Finished tests fo...
511
512
513
514
515
    def test_5_seq_status(self):
        '''
            goal: test the evolution of sequences status
            conditions: 5 identical sequences with different status at the beginning
        '''
94336356   haribo   Added starting fi...
516

b87b6d9b   haribo   Finished tests fo...
517
518
519
520
521
        print("\n===== TEST_5_SEQ_STATUS =====\n")

        self.scheduler.schedule.plan_start = 0
        self.scheduler.schedule.plan_end = 200

b87b6d9b   haribo   Finished tests fo...
522
        ''' create the sequences '''
7a79e25b   haribo   Date: 19/05/2016
523
        seq1 = Sequence.objects.create(request=self.req1, status=Sequence.TOBEPLANNED,
94336356   haribo   Added starting fi...
524
                                       name="seq1", jd1=0, jd2=200, priority=1, t_prefered=-1, duration=20)
4b503f5c   jeremy   Update installer ...
525
        seq2 = Sequence.objects.create(request=self.req2, status=Sequence.TOBEPLANNED,
94336356   haribo   Added starting fi...
526
                                       name="seq2", jd1=0, jd2=200, priority=1, t_prefered=-1, duration=20)
7a79e25b   haribo   Date: 19/05/2016
527
        seq3 = Sequence.objects.create(request=self.req3, status=Sequence.EXECUTED,
94336356   haribo   Added starting fi...
528
                                       name="seq3", jd1=0, jd2=200, priority=1, t_prefered=-1, duration=20)
7a79e25b   haribo   Date: 19/05/2016
529
        seq4 = Sequence.objects.create(request=self.req3, status=Sequence.REJECTED,
94336356   haribo   Added starting fi...
530
                                       name="seq4", jd1=0, jd2=200, priority=1, t_prefered=-1, duration=20)
7a79e25b   haribo   Date: 19/05/2016
531
        seq5 = Sequence.objects.create(request=self.req3, status=Sequence.UNPLANNABLE,
94336356   haribo   Added starting fi...
532
                                       name="seq5", jd1=0, jd2=200, priority=1, t_prefered=-1, duration=20)
b87b6d9b   haribo   Finished tests fo...
533
534

        ''' compute and print the schedule '''
bca9a283   Jeremy   Reworked the sche...
535
        self.scheduler.makeSchedule()
7a79e25b   haribo   Date: 19/05/2016
536
537
538

        sched = Schedule.objects.order_by('-created')[0]
        shs_list = sched.shs.all()
4b503f5c   jeremy   Update installer ...
539
        nbPlanned = len([shs for shs in shs_list if shs.status == Sequence.PLANNED])
94336356   haribo   Added starting fi...
540

7a79e25b   haribo   Date: 19/05/2016
541
        shs2 = next(shs for shs in shs_list if shs.sequence == seq2)
b87b6d9b   haribo   Finished tests fo...
542
543
544
545
546
547
548
549

        seq1 = Sequence.objects.get(name="seq1")
        seq2 = Sequence.objects.get(name="seq2")
        seq3 = Sequence.objects.get(name="seq3")
        seq4 = Sequence.objects.get(name="seq4")
        seq5 = Sequence.objects.get(name="seq5")

        ''' checks sequences status '''
94336356   haribo   Added starting fi...
550

4b503f5c   jeremy   Update installer ...
551
        self.assertEqual(nbPlanned, 2)
94336356   haribo   Added starting fi...
552

4b503f5c   jeremy   Update installer ...
553
554
        self.assertEqual(seq1.status, Sequence.PLANNED)
        self.assertEqual(shs2.status, Sequence.PLANNED)
b87b6d9b   haribo   Finished tests fo...
555
556
557
558
        self.assertEqual(seq3.status, Sequence.EXECUTED)
        self.assertEqual(seq4.status, Sequence.REJECTED)
        self.assertEqual(seq5.status, Sequence.UNPLANNABLE)

b87b6d9b   haribo   Finished tests fo...
559
560
    def test_4_seq_eligibility(self):
        '''
05bdcc44   Etienne Pallier   BIG DEMO tests (s...
561
            goal: test if ineligible sequences are programmed
715fabb7   haribo   #3430 (100%)
562
            conditions: only ineligible sequences
b87b6d9b   haribo   Finished tests fo...
563
        '''
94336356   haribo   Added starting fi...
564

b87b6d9b   haribo   Finished tests fo...
565
566
        print("\n===== TEST_4_SEQ_ELIGIBILITY =====\n")

05bdcc44   Etienne Pallier   BIG DEMO tests (s...
567
568
569
570
571
572
        # Check that only 1 EMPTY schedule is available in DB (because of Scheduler() instance created in setup())
        self.assertEqual(len(Schedule.objects.all()) , 1)
        sched = Schedule.objects.order_by('-created')[0]
        print("schedule is", sched)
        self.assertEqual(len(sched.shs.all()), 0)

b87b6d9b   haribo   Finished tests fo...
573
574
575
        self.scheduler.schedule.plan_start = 100
        self.scheduler.schedule.plan_end = 200

05bdcc44   Etienne Pallier   BIG DEMO tests (s...
576
        ''' create 4 sequences (to be planned) with default status TOBEPLANNED '''
4b503f5c   jeremy   Update installer ...
577
        seq1 = Sequence.objects.create(request=self.req1, status=Sequence.TOBEPLANNED,
94336356   haribo   Added starting fi...
578
                                       name="seq1", jd1=0, jd2=110, priority=1, t_prefered=-1, duration=20)
4b503f5c   jeremy   Update installer ...
579
        seq2 = Sequence.objects.create(request=self.req2, status=Sequence.TOBEPLANNED,
94336356   haribo   Added starting fi...
580
                                       name="seq2", jd1=181, jd2=300, priority=1, t_prefered=-1, duration=20)
4b503f5c   jeremy   Update installer ...
581
        seq3 = Sequence.objects.create(request=self.req3, status=Sequence.TOBEPLANNED,
94336356   haribo   Added starting fi...
582
                                       name="seq3", jd1=50, jd2=90, priority=1, t_prefered=-1, duration=20)
4b503f5c   jeremy   Update installer ...
583
        seq4 = Sequence.objects.create(request=self.req3, status=Sequence.TOBEPLANNED,
94336356   haribo   Added starting fi...
584
                                       name="seq4", jd1=300, jd2=400, priority=1, t_prefered=-1, duration=20)
05bdcc44   Etienne Pallier   BIG DEMO tests (s...
585
586
587
588
        #for s in (seq1,seq2,seq3,seq4): print(s.status)

        # Check that we now have exactly 4 sequences in DB
        self.assertEqual(len(Sequence.objects.all()) , 4)
b87b6d9b   haribo   Finished tests fo...
589
590

        ''' compute and print the schedule '''
bca9a283   Jeremy   Reworked the sche...
591
        self.scheduler.makeSchedule()
94336356   haribo   Added starting fi...
592

05bdcc44   Etienne Pallier   BIG DEMO tests (s...
593
594
595
        # Check that still only 1 schedule available in DB, and 0 sequence in it
        self.assertEqual(len(Schedule.objects.all()) , 1)
        # Get the last (more recent) schedule saved by makeSchedule()
7a79e25b   haribo   Date: 19/05/2016
596
        sched = Schedule.objects.order_by('-created')[0]
05bdcc44   Etienne Pallier   BIG DEMO tests (s...
597
        print("updated schedule is", sched, "with night start", sched.plan_night_start)
7a79e25b   haribo   Date: 19/05/2016
598
        shs_list = sched.shs.all()
05bdcc44   Etienne Pallier   BIG DEMO tests (s...
599
600
        # EP added
        self.assertEqual(len(shs_list), 0)
4b503f5c   jeremy   Update installer ...
601
        nbPlanned = len([shs for shs in shs_list if shs.status == Sequence.PLANNED])
05bdcc44   Etienne Pallier   BIG DEMO tests (s...
602
        self.assertEqual(nbPlanned, 0)
b87b6d9b   haribo   Finished tests fo...
603

05bdcc44   Etienne Pallier   BIG DEMO tests (s...
604
        ''' checks sequences status '''
b87b6d9b   haribo   Finished tests fo...
605
606
607
608
609
        seq1 = Sequence.objects.get(name="seq1")
        seq2 = Sequence.objects.get(name="seq2")
        seq3 = Sequence.objects.get(name="seq3")
        seq4 = Sequence.objects.get(name="seq4")

05bdcc44   Etienne Pallier   BIG DEMO tests (s...
610
        for s in (seq1,seq2,seq3,seq4): print(s.status)
b87b6d9b   haribo   Finished tests fo...
611
        self.assertEqual(seq1.status, Sequence.UNPLANNABLE)
4b503f5c   jeremy   Update installer ...
612
        self.assertEqual(seq2.status, Sequence.TOBEPLANNED)
b87b6d9b   haribo   Finished tests fo...
613
        self.assertEqual(seq3.status, Sequence.UNPLANNABLE)
4b503f5c   jeremy   Update installer ...
614
        self.assertEqual(seq4.status, Sequence.TOBEPLANNED)
b87b6d9b   haribo   Finished tests fo...
615

05bdcc44   Etienne Pallier   BIG DEMO tests (s...
616

b87b6d9b   haribo   Finished tests fo...
617
618
619
620
    def test_invalid_sequences(self):
        '''
            goal: test if the scheduler is able to plan invalid sequences (it shouldn't)
        '''
94336356   haribo   Added starting fi...
621

b87b6d9b   haribo   Finished tests fo...
622
623
624
625
626
        print("\n===== TEST_INVALID_SEQUENCES =====\n")

        self.scheduler.schedule.plan_start = 0
        self.scheduler.schedule.plan_end = 200

b87b6d9b   haribo   Finished tests fo...
627
        ''' create the sequences '''
4b503f5c   jeremy   Update installer ...
628
        seq1 = Sequence.objects.create(request=self.req1, status=Sequence.TOBEPLANNED,
94336356   haribo   Added starting fi...
629
                                       name="seq1", jd1=190, jd2=110, priority=1, t_prefered=-1, duration=20)
4b503f5c   jeremy   Update installer ...
630
        seq2 = Sequence.objects.create(request=self.req2, status=Sequence.TOBEPLANNED,
94336356   haribo   Added starting fi...
631
                                       name="seq2", jd1=20, jd2=30, priority=1, t_prefered=-1, duration=20)
4b503f5c   jeremy   Update installer ...
632
        seq3 = Sequence.objects.create(request=self.req3, status=Sequence.TOBEPLANNED,
94336356   haribo   Added starting fi...
633
                                       name="seq3", jd1=50, jd2=90, priority=1, t_prefered=-1, duration=0)
4b503f5c   jeremy   Update installer ...
634
        seq4 = Sequence.objects.create(request=self.req3, status=Sequence.TOBEPLANNED,
94336356   haribo   Added starting fi...
635
                                       name="seq4", jd1=50, jd2=90, priority=1, t_prefered=-1, duration=-10)
b87b6d9b   haribo   Finished tests fo...
636
637

        ''' compute and print the schedule '''
bca9a283   Jeremy   Reworked the sche...
638
        self.scheduler.makeSchedule()
94336356   haribo   Added starting fi...
639

7a79e25b   haribo   Date: 19/05/2016
640
641
        sched = Schedule.objects.order_by('-created')[0]
        shs_list = sched.shs.all()
4b503f5c   jeremy   Update installer ...
642
        nbPlanned = len([shs for shs in shs_list if shs.status == Sequence.PLANNED])
b87b6d9b   haribo   Finished tests fo...
643
644
645
646
647
648
649

        seq1 = Sequence.objects.get(name="seq1")
        seq2 = Sequence.objects.get(name="seq2")
        seq3 = Sequence.objects.get(name="seq3")
        seq4 = Sequence.objects.get(name="seq4")

        ''' checks sequences status '''
94336356   haribo   Added starting fi...
650

b87b6d9b   haribo   Finished tests fo...
651
652
653
654
        self.assertEqual(seq1.status, Sequence.INVALID)
        self.assertEqual(seq2.status, Sequence.INVALID)
        self.assertEqual(seq3.status, Sequence.INVALID)
        self.assertEqual(seq4.status, Sequence.INVALID)
bca9a283   Jeremy   Reworked the sche...
655
        self.assertEqual(nbPlanned, 0)
a2283bf3   haribo   Date: 20/05/2016
656
657
658
659
660
661
662
663
664
665

    def test_simulation(self):
        '''
            goal : Uses the simulation module to make a schedule and test the validity of created sequences
        '''

        print("\n===== TEST_SIMULATION =====\n")

        simulator = Simulator()
        simulator.simulate(SIMULATION_FILE)