|
| 1 | +# |
| 2 | +# Copyright (C) 2014 Shang Yuanchun <[email protected]> |
| 3 | +# |
| 4 | +# |
| 5 | +# You may redistribute it and/or modify it under the terms of the |
| 6 | +# GNU General Public License, as published by the Free Software |
| 7 | +# Foundation; either version 3 of the License, or (at your option) |
| 8 | +# any later version. |
| 9 | +# |
| 10 | +# mirror 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. |
| 13 | +# See the GNU General Public License for more details. |
| 14 | +# |
| 15 | +# You should have received a copy of the GNU General Public License |
| 16 | +# along with mirror. If not, write to: |
| 17 | +# The Free Software Foundation, Inc., |
| 18 | +# 51 Franklin Street, Fifth Floor |
| 19 | +# Boston, MA 02110-1301, USA. |
| 20 | +# |
| 21 | +# |
| 22 | + |
| 23 | +import unittest |
| 24 | + |
| 25 | +from mirror.queue import TaskInfo |
| 26 | +from mirror.queue import Queue |
| 27 | + |
| 28 | +class TaskQueueTestCase(unittest.TestCase): |
| 29 | + |
| 30 | + def test_taskqueue(self): |
| 31 | + task1 = TaskInfo("Buy clock", 0, 1376712000, 2) |
| 32 | + task2 = TaskInfo("Basketball", 0, 1376701200, 1) |
| 33 | + task3 = TaskInfo("Wash clothes", 0, 1376701200, 2) |
| 34 | + task4 = TaskInfo("Send letter", 0, 1376704800, 4) |
| 35 | + |
| 36 | + queue = Queue(task1, task2, task3, task4, "Qiandao Lake") |
| 37 | + self.assertEqual(queue.size(), 4) |
| 38 | + self.assertEqual(queue.empty(), False) |
| 39 | + |
| 40 | + # it is Basketball |
| 41 | + task = queue[0] |
| 42 | + self.assertEqual(task.name, "Basketball") |
| 43 | + self.assertEqual(task.time, 1376701200) |
| 44 | + |
| 45 | +if __name__ == '__main__': |
| 46 | + unittest.main() |
0 commit comments