frontend.shared.rest_client: Fix reference to an undefined variable
[autotest-zwu.git] / cli / rpc_unittest.py
blob0e87e4d984bc82c8d5cca7c968c9c31d261ab666
1 #!/usr/bin/python
3 # Copyright 2008 Google Inc. All Rights Reserved.
5 """Test for the rpc proxy class."""
7 import unittest, os
8 import common
9 from autotest_lib.cli import rpc
10 from autotest_lib.client.common_lib import global_config
11 from autotest_lib.frontend.afe import rpc_client_lib
12 from autotest_lib.frontend.afe.json_rpc import proxy
14 GLOBAL_CONFIG = global_config.global_config
17 class rpc_unittest(unittest.TestCase):
18 def setUp(self):
19 self.old_environ = os.environ.copy()
20 if 'AUTOTEST_WEB' in os.environ:
21 del os.environ['AUTOTEST_WEB']
24 def tearDown(self):
25 os.environ.clear()
26 os.environ.update(self.old_environ)
29 def test_get_autotest_server_specific(self):
30 self.assertEqual('http://foo', rpc.get_autotest_server('foo'))
33 def test_get_autotest_server_none(self):
34 GLOBAL_CONFIG.override_config_value('SERVER', 'hostname', 'Prince')
35 self.assertEqual('http://Prince', rpc.get_autotest_server(None))
38 def test_get_autotest_server_environ(self):
39 os.environ['AUTOTEST_WEB'] = 'foo-dev'
40 self.assertEqual('http://foo-dev', rpc.get_autotest_server(None))
41 del os.environ['AUTOTEST_WEB']
44 def test_get_autotest_server_environ_precedence(self):
45 os.environ['AUTOTEST_WEB'] = 'foo-dev'
46 self.assertEqual('http://foo', rpc.get_autotest_server('foo'))
47 del os.environ['AUTOTEST_WEB']
50 if __name__ == '__main__':
51 unittest.main()