• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/python2
2#
3# Copyright 2014 The Chromium OS Authors. All rights reserved.
4# Use of this source code is governed by a BSD-style license that can be
5# found in the LICENSE file.
6
7import unittest
8
9import common
10from autotest_lib.server.cros import dnsname_mangler
11
12HOST = 'chromeos1-row1-rack1-host1'
13ROUTER = 'chromeos1-row1-rack1-host1-router'
14ATTENUATOR = 'chromeos1-row1-rack1-host1-attenuator'
15
16HOST_FROM_OUTSIDE_LAB = HOST + '.cros'
17ROUTER_FROM_OUTSIDE_LAB = ROUTER + '.cros'
18ATTENUATOR_FROM_OUTSIDE_LAB = ATTENUATOR + '.cros'
19
20
21class DnsnameMangerUnittest(unittest.TestCase):
22    """Check that we're correctly mangling DNS names."""
23
24
25    def testRouterNamesCorrect(self):
26        """Router names should look like <dut_dns_name>-router[.cros]"""
27        self.assertEquals(ROUTER, dnsname_mangler.get_router_addr(HOST))
28        self.assertEquals(
29                ROUTER_FROM_OUTSIDE_LAB,
30                dnsname_mangler.get_router_addr(HOST_FROM_OUTSIDE_LAB))
31
32
33    def testAttenuatorNamesCorrect(self):
34        """Router names should look like <dut_dns_name>-attenuator[.cros]"""
35        self.assertEquals(ATTENUATOR, dnsname_mangler.get_attenuator_addr(HOST))
36        self.assertEquals(
37                ATTENUATOR_FROM_OUTSIDE_LAB,
38                dnsname_mangler.get_attenuator_addr(HOST_FROM_OUTSIDE_LAB))
39
40
41if __name__ == '__main__':
42    unittest.main()
43