3 # Copyright 2008 Google Inc. All Rights Reserved.
5 """Test for the rpc proxy class."""
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
):
19 self
.old_environ
= os
.environ
.copy()
20 if 'AUTOTEST_WEB' in os
.environ
:
21 del os
.environ
['AUTOTEST_WEB']
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__':