Blame view

src/core/pyros_django/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

f49b7078   Etienne Pallier   Bugfix tests and ...
6
7
import os

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

bca9a283   Jeremy   Reworked the sche...
10

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

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

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

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

7a79e25b   haribo   Date: 19/05/2016
25
26
        self.scheduler.max_overhead = 1

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

53787d30   Jeremy   Alert now inherit...
31
32
33
        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...
34

ee2c4543   Etienne Pallier   Bugfix Monitoring...
35
36
37
        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...
38

b87b6d9b   haribo   Finished tests fo...
39
40
41
42
43
    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...
44

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

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

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

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

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

bca9a283   Jeremy   Reworked the sche...
65
66
        self.assertEqual(nbPlanned, 3)

7a79e25b   haribo   Date: 19/05/2016
67
68
69
        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...
70
71

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

7a79e25b   haribo   Date: 19/05/2016
73
74
75
76
        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...
77

7a79e25b   haribo   Date: 19/05/2016
78
79
80
81
        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...
82

7a79e25b   haribo   Date: 19/05/2016
83
84
85
86
        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...
87

b87b6d9b   haribo   Finished tests fo...
88
89
90
91
92
    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...
93

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

b87b6d9b   haribo   Finished tests fo...
107
108
109
110
111
112
113
114
        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...
115
        self.scheduler.makeSchedule()
94336356   haribo   Added starting fi...
116

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

        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...
126

b87b6d9b   haribo   Finished tests fo...
127
128
129
130
131
132
133
134
135
136
137
        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...
138

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

b87b6d9b   haribo   Finished tests fo...
154
155
156
157
158
159
160
161
        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...
162
        self.scheduler.makeSchedule()
94336356   haribo   Added starting fi...
163

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

        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...
174

b87b6d9b   haribo   Finished tests fo...
175
176
177
178
179
180
181
182
183
184
185
        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...
186

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

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

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

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

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

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

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

b87b6d9b   haribo   Finished tests fo...
211
212
        self.assertEqual(nbPlanned, 1)

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

b87b6d9b   haribo   Finished tests fo...
215
216
217
218
219
    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...
220

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

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

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

7a79e25b   haribo   Date: 19/05/2016
241
242
243
        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...
244
245

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

b87b6d9b   haribo   Finished tests fo...
247
248
        self.assertEqual(nbPlanned, 3)

7a79e25b   haribo   Date: 19/05/2016
249
250
251
252
        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...
253

7a79e25b   haribo   Date: 19/05/2016
254
255
256
257
        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...
258

7a79e25b   haribo   Date: 19/05/2016
259
260
261
262
        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...
263
264
265
266
267
268

    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...
269

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

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

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

bca9a283   Jeremy   Reworked the sche...
290
291
        self.assertEqual(nbPlanned, 3)

7a79e25b   haribo   Date: 19/05/2016
292
293
294
        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...
295
296

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

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

7a79e25b   haribo   Date: 19/05/2016
300
301
302
303
        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...
304

7a79e25b   haribo   Date: 19/05/2016
305
306
307
308
        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...
309

7a79e25b   haribo   Date: 19/05/2016
310
311
312
313
        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...
314
315
316
317
318
319

    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...
320

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

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

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

bca9a283   Jeremy   Reworked the sche...
341
342
        self.assertEqual(nbPlanned, 3)

7a79e25b   haribo   Date: 19/05/2016
343
344
345
        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...
346
347

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

b87b6d9b   haribo   Finished tests fo...
349

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

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

92039557   haribo   Minor fix : t_pre...
360
361
362
363
        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...
364
365
366
367
368

    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...
369
370
        '''

b87b6d9b   haribo   Finished tests fo...
371
372
373
        print("\n===== TEST_3_SEQ_MOVE_LEFT =====\n")

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

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

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

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

bca9a283   Jeremy   Reworked the sche...
391
392
        self.assertEqual(nbPlanned, 3)

7a79e25b   haribo   Date: 19/05/2016
393
394
395
        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...
396
397

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

7a79e25b   haribo   Date: 19/05/2016
399
400
401
402
        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...
403

7a79e25b   haribo   Date: 19/05/2016
404
405
406
407
        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...
408

7a79e25b   haribo   Date: 19/05/2016
409
410
411
412
        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...
413
414
415
416
417

    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...
418
419
        '''

b87b6d9b   haribo   Finished tests fo...
420
421
422
        print("\n===== TEST_3_SEQ_MOVE_RIGHT =====\n")

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

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

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

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

bca9a283   Jeremy   Reworked the sche...
440
441
        self.assertEqual(nbPlanned, 3)

7a79e25b   haribo   Date: 19/05/2016
442
443
444
        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...
445
446

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

b87b6d9b   haribo   Finished tests fo...
448

7a79e25b   haribo   Date: 19/05/2016
449
450
451
452
        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...
453

7a79e25b   haribo   Date: 19/05/2016
454
455
456
457
        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...
458

7a79e25b   haribo   Date: 19/05/2016
459
460
461
462
        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...
463

b87b6d9b   haribo   Finished tests fo...
464
465
466
467
    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...
468
469
        '''

b87b6d9b   haribo   Finished tests fo...
470
471
472
        print("\n===== TEST_3_SEQ_MOVE_BOTH =====\n")

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

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

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

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

bca9a283   Jeremy   Reworked the sche...
490
491
        self.assertEqual(nbPlanned, 3)

7a79e25b   haribo   Date: 19/05/2016
492
493
494
        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...
495
496

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

7a79e25b   haribo   Date: 19/05/2016
498
499
500
501
        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...
502

7a79e25b   haribo   Date: 19/05/2016
503
504
505
506
        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...
507

7a79e25b   haribo   Date: 19/05/2016
508
509
510
511
        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...
512

b87b6d9b   haribo   Finished tests fo...
513
514
515
516
517
    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...
518

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

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

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

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

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

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

        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...
552

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

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

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

b87b6d9b   haribo   Finished tests fo...
567
568
        print("\n===== TEST_4_SEQ_ELIGIBILITY =====\n")

05bdcc44   Etienne Pallier   BIG DEMO tests (s...
569
570
571
572
573
574
        # 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...
575
576
577
        self.scheduler.schedule.plan_start = 100
        self.scheduler.schedule.plan_end = 200

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

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

05bdcc44   Etienne Pallier   BIG DEMO tests (s...
595
596
597
        # 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
598
        sched = Schedule.objects.order_by('-created')[0]
05bdcc44   Etienne Pallier   BIG DEMO tests (s...
599
        print("updated schedule is", sched, "with night start", sched.plan_night_start)
7a79e25b   haribo   Date: 19/05/2016
600
        shs_list = sched.shs.all()
05bdcc44   Etienne Pallier   BIG DEMO tests (s...
601
602
        # EP added
        self.assertEqual(len(shs_list), 0)
4b503f5c   jeremy   Update installer ...
603
        nbPlanned = len([shs for shs in shs_list if shs.status == Sequence.PLANNED])
05bdcc44   Etienne Pallier   BIG DEMO tests (s...
604
        self.assertEqual(nbPlanned, 0)
b87b6d9b   haribo   Finished tests fo...
605

05bdcc44   Etienne Pallier   BIG DEMO tests (s...
606
        ''' checks sequences status '''
b87b6d9b   haribo   Finished tests fo...
607
608
609
610
611
        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...
612
        for s in (seq1,seq2,seq3,seq4): print(s.status)
b87b6d9b   haribo   Finished tests fo...
613
        self.assertEqual(seq1.status, Sequence.UNPLANNABLE)
4b503f5c   jeremy   Update installer ...
614
        self.assertEqual(seq2.status, Sequence.TOBEPLANNED)
b87b6d9b   haribo   Finished tests fo...
615
        self.assertEqual(seq3.status, Sequence.UNPLANNABLE)
4b503f5c   jeremy   Update installer ...
616
        self.assertEqual(seq4.status, Sequence.TOBEPLANNED)
b87b6d9b   haribo   Finished tests fo...
617

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

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

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

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

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

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

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

        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...
652

b87b6d9b   haribo   Finished tests fo...
653
654
655
656
        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...
657
        self.assertEqual(nbPlanned, 0)
a2283bf3   haribo   Date: 20/05/2016
658
659
660
661
662
663
664
665
666

    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()
f49b7078   Etienne Pallier   Bugfix tests and ...
667
        print("current dir is", os.getcwd())
a2283bf3   haribo   Date: 20/05/2016
668
        simulator.simulate(SIMULATION_FILE)