diff --git a/swh/scheduler/tests/test_task.py b/swh/scheduler/tests/test_task.py new file mode 100644 index 0000000..bdcd205 --- /dev/null +++ b/swh/scheduler/tests/test_task.py @@ -0,0 +1,31 @@ +# Copyright (C) 2015 The Software Heritage developers +# See the AUTHORS file at the top-level directory of this distribution +# License: GNU General Public License version 3, or any later version +# See top-level LICENSE file for more information + +import unittest + +from nose.tools import istest + +from swh.scheduler import task + + +class Task(unittest.TestCase): + + @istest + def not_implemented_task(self): + class NotImplementedTask(task.Task): + pass + + with self.assertRaises(NotImplementedError): + NotImplementedTask().run() + + @istest + def add_task(self): + class AddTask(task.Task): + def run(self, x, y): + return x + y + + r = AddTask().apply([2, 3]) + self.assertTrue(r.successful()) + self.assertEqual(r.result, 5)