showard | ed2afea | 2009-07-07 20:54:07 +0000 | [diff] [blame] | 1 | #!/usr/bin/python |
| 2 | |
| 3 | import unittest |
| 4 | import common |
| 5 | from autotest_lib.frontend import setup_django_environment |
| 6 | from autotest_lib.frontend.afe import frontend_test_utils |
| 7 | from autotest_lib.frontend.afe import models |
| 8 | |
| 9 | class SpecialTaskUnittest(unittest.TestCase, |
| 10 | frontend_test_utils.FrontendTestMixin): |
| 11 | def setUp(self): |
| 12 | self._frontend_common_setup() |
| 13 | |
| 14 | |
| 15 | def tearDown(self): |
| 16 | self._frontend_common_teardown() |
| 17 | |
| 18 | |
showard | c0ac3a7 | 2009-07-08 21:14:45 +0000 | [diff] [blame^] | 19 | def _create_task(self): |
| 20 | return models.SpecialTask.objects.create( |
showard | ed2afea | 2009-07-07 20:54:07 +0000 | [diff] [blame] | 21 | host=self.hosts[0], task=models.SpecialTask.Task.VERIFY) |
| 22 | |
showard | c0ac3a7 | 2009-07-08 21:14:45 +0000 | [diff] [blame^] | 23 | |
| 24 | def test_execution_path(self): |
| 25 | task = self._create_task() |
showard | ed2afea | 2009-07-07 20:54:07 +0000 | [diff] [blame] | 26 | self.assertEquals(task.execution_path(), 'hosts/host1/1-verify') |
| 27 | |
| 28 | |
showard | c0ac3a7 | 2009-07-08 21:14:45 +0000 | [diff] [blame^] | 29 | def test_status(self): |
| 30 | task = self._create_task() |
| 31 | self.assertEquals(task.status, 'Queued') |
| 32 | |
| 33 | task.update_object(is_active=True) |
| 34 | self.assertEquals(task.status, 'Running') |
| 35 | |
| 36 | task.update_object(is_active=False, is_complete=True) |
| 37 | self.assertEquals(task.status, 'Completed') |
| 38 | |
| 39 | |
showard | ed2afea | 2009-07-07 20:54:07 +0000 | [diff] [blame] | 40 | if __name__ == '__main__': |
| 41 | unittest.main() |