jamesren | cd7a81a | 2010-04-21 20:39:08 +0000 | [diff] [blame^] | 1 | #!/usr/bin/python |
| 2 | |
| 3 | import common |
| 4 | import unittest |
| 5 | from autotest_lib.frontend import setup_django_environment |
| 6 | from autotest_lib.frontend import setup_test_environment |
| 7 | from autotest_lib.client.common_lib.test_utils import mock |
| 8 | from autotest_lib.frontend.shared import resource_test_utils |
| 9 | from autotest_lib.frontend.tko import models, rpc_interface_unittest |
| 10 | |
| 11 | |
| 12 | class TkoResourceTestCase(resource_test_utils.ResourceTestCase, |
| 13 | rpc_interface_unittest.TkoTestMixin): |
| 14 | URI_PREFIX = 'http://testserver/new_tko/server/resources' |
| 15 | |
| 16 | def setUp(self): |
| 17 | super(TkoResourceTestCase, self).setUp() |
| 18 | self.god = mock.mock_god() |
| 19 | self._patch_sqlite_stuff() |
| 20 | self._create_initial_data() |
| 21 | |
| 22 | |
| 23 | def tearDown(self): |
| 24 | super(TkoResourceTestCase, self).tearDown() |
| 25 | self.god.unstub_all() |
| 26 | |
| 27 | |
| 28 | class TestResultTest(TkoResourceTestCase): |
| 29 | def test_collection(self): |
| 30 | response = self.request('get', 'test_results') |
| 31 | self.check_collection(response, 'test_name', |
| 32 | ['kernbench', 'mytest1', 'mytest2']) |
| 33 | |
| 34 | |
| 35 | def test_filter_afe_job_id(self): |
| 36 | response = self.request('get', 'test_results?afe_job_id=1') |
| 37 | self.check_collection(response, 'test_name', ['mytest1', 'mytest2']) |
| 38 | |
| 39 | |
| 40 | def test_entry(self): |
| 41 | response = self.request('get', 'test_results/1') |
| 42 | self.assertEquals(response['test_name'], 'mytest1') |
| 43 | self.assertEquals(response['status'], 'GOOD') |
| 44 | self.assertEquals(response['reason'], '') |
| 45 | |
| 46 | |
| 47 | if __name__ == '__main__': |
| 48 | unittest.main() |