• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2019 The Chromium OS Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5import ConfigParser
6import io
7import unittest
8
9import common
10from autotest_lib.server.cros import ap_config
11
12
13class APTestCase(unittest.TestCase):
14    def test_not_rpm_managed(self):
15        conf = _parse_config_from_string("""
16[test_bss]
17rpm_managed = False
18rpm_hostname = chromeos3-row2-rack3-rpm1
19rpm_outlet = .A15""")
20        ap = ap_config.AP('test_bss', conf)
21        self.assertIsNone(ap.get_rpm_unit())
22
23
24    def test_rpm_managed(self):
25        conf = _parse_config_from_string("""
26[test_bss]
27rpm_managed = True
28rpm_hostname = chromeos3-row2-rack3-rpm1
29rpm_outlet = .A15""")
30        ap = ap_config.AP('test_bss', conf)
31        rpm_unit = ap.get_rpm_unit()
32        self.assertIsNotNone(rpm_unit)
33        self.assertEqual('chromeos3-row2-rack3-rpm1', rpm_unit.hostname)
34        self.assertEqual('.A15', rpm_unit.outlet)
35
36    def test_get_ap_list_returns_non_empty(self):
37        self.assertGreater(len(ap_config.get_ap_list()), 0)
38
39
40def _parse_config_from_string(conf):
41    parser = ConfigParser.RawConfigParser()
42    parser.readfp(io.BytesIO(conf))
43    return parser
44
45
46if __name__ == '__main__':
47    unittest.main()