Michael Tang | 84a2ecf | 2016-06-07 15:10:53 -0700 | [diff] [blame] | 1 | #!/usr/bin/python |
| 2 | # |
| 3 | # Copyright (c) 2016 The Chromium OS Authors. All rights reserved. |
| 4 | # Use of this source code is governed by a BSD-style license that can be |
| 5 | # found in the LICENSE file. |
| 6 | |
| 7 | """Unit tests for frontend/afe/rpc_utils.py.""" |
| 8 | |
| 9 | |
| 10 | import unittest |
| 11 | |
| 12 | import common |
| 13 | from autotest_lib.client.common_lib import control_data |
| 14 | from autotest_lib.frontend import setup_django_environment |
| 15 | from autotest_lib.frontend.afe import frontend_test_utils |
| 16 | from autotest_lib.frontend.afe import rpc_utils |
| 17 | |
| 18 | |
| 19 | class RpcUtilsTest(unittest.TestCase, |
| 20 | frontend_test_utils.FrontendTestMixin): |
| 21 | """Unit tests for functions in rpc_utils.py.""" |
| 22 | def setUp(self): |
| 23 | self._frontend_common_setup() |
| 24 | |
| 25 | |
| 26 | def tearDown(self): |
| 27 | self._frontend_common_teardown() |
| 28 | |
| 29 | |
| 30 | def testCheckIsServer(self): |
| 31 | """Ensure that test type check is correct.""" |
| 32 | self.assertFalse(rpc_utils._check_is_server_test(None)) |
| 33 | self.assertFalse(rpc_utils._check_is_server_test( |
| 34 | control_data.CONTROL_TYPE.CLIENT)) |
| 35 | self.assertFalse(rpc_utils._check_is_server_test('Client')) |
| 36 | self.assertTrue(rpc_utils._check_is_server_test( |
| 37 | control_data.CONTROL_TYPE.SERVER)) |
| 38 | self.assertTrue(rpc_utils._check_is_server_test('Server')) |
| 39 | self.assertFalse(rpc_utils._check_is_server_test('InvalidType')) |
| 40 | |
| 41 | |
| 42 | if __name__ == '__main__': |
| 43 | unittest.main() |