3 # NEPI, a framework to manage network experiments
4 # Copyright (C) 2013 INRIA
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License version 2 as
8 # published by the Free Software Foundation;
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18 # Author: Alina Quereilhac <alina.quereilhac@inria.fr>
20 from nepi.execution.scheduler import HeapScheduler, Task, TaskStatus
21 from nepi.util.timefuncs import tnow, stabsformat
27 class SchedulerTestCase(unittest.TestCase):
28 def test_task_order(self):
38 scheduler = HeapScheduler()
41 t2 = stabsformat("2s")
42 t3 = stabsformat("3s")
44 tsk1 = Task(t1, first)
45 tsk2 = Task(t2, second)
46 tsk3 = Task(t3, third)
48 # schedule the tasks in disorder
49 scheduler.schedule(tsk2)
50 scheduler.schedule(tsk3)
51 scheduler.schedule(tsk1)
53 # Make sure tasks are retrieved in teh correct order
55 self.assertEqual(tsk.callback(), 1)
58 self.assertEqual(tsk.callback(), 2)
61 self.assertEqual(tsk.callback(), 3)
64 if __name__ == '__main__':