• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/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
10from autotest_lib.client.common_lib import global_config
11from autotest_lib.frontend.afe import rpc_client_lib
12from autotest_lib.frontend.afe.json_rpc import proxy
13
14GLOBAL_CONFIG = global_config.global_config
15
16
17class 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']
22
23
24    def tearDown(self):
25        os.environ.clear()
26        os.environ.update(self.old_environ)
27
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):
34        GLOBAL_CONFIG.override_config_value('SERVER', 'hostname', 'Prince')
35        self.assertEqual('http://Prince', rpc.get_autotest_server(None))
36
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()
52