blob: 0e87e4d984bc82c8d5cca7c968c9c31d261ab666 [file] [log] [blame]
mblighbe630eb2008-08-01 16:41:48 +00001#!/usr/bin/python
2#
3# Copyright 2008 Google Inc. All Rights Reserved.
4
5"""Test for the rpc proxy class."""
6
7import unittest, os
8import common
9from autotest_lib.cli import rpc
mblighf8d456f2008-12-22 14:46:52 +000010from autotest_lib.client.common_lib import global_config
mblighbe630eb2008-08-01 16:41:48 +000011from autotest_lib.frontend.afe import rpc_client_lib
12from autotest_lib.frontend.afe.json_rpc import proxy
13
mblighf8d456f2008-12-22 14:46:52 +000014GLOBAL_CONFIG = global_config.global_config
15
mblighbe630eb2008-08-01 16:41:48 +000016
17class rpc_unittest(unittest.TestCase):
18 def setUp(self):
mblighf8d456f2008-12-22 14:46:52 +000019 self.old_environ = os.environ.copy()
mblighbe630eb2008-08-01 16:41:48 +000020 if 'AUTOTEST_WEB' in os.environ:
21 del os.environ['AUTOTEST_WEB']
22
23
24 def tearDown(self):
mblighf8d456f2008-12-22 14:46:52 +000025 os.environ.clear()
26 os.environ.update(self.old_environ)
mblighbe630eb2008-08-01 16:41:48 +000027
28
29 def test_get_autotest_server_specific(self):
30 self.assertEqual('http://foo', rpc.get_autotest_server('foo'))
31
32
33 def test_get_autotest_server_none(self):
mblighf8d456f2008-12-22 14:46:52 +000034 GLOBAL_CONFIG.override_config_value('SERVER', 'hostname', 'Prince')
35 self.assertEqual('http://Prince', rpc.get_autotest_server(None))
mblighbe630eb2008-08-01 16:41:48 +000036
37
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']
42
43
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']
48
49
50if __name__ == '__main__':
51 unittest.main()