Home | History | Annotate | Download | only in cros
      1 #!/usr/bin/python
      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 
      7 import unittest
      8 
      9 import common
     10 from autotest_lib.server.cros import dnsname_mangler
     11 
     12 HOST = 'chromeos1-row1-rack1-host1'
     13 ROUTER = 'chromeos1-row1-rack1-host1-router'
     14 ATTENUATOR = 'chromeos1-row1-rack1-host1-attenuator'
     15 TESTER = 'chromeos1-row1-rack1-host1-router'
     16 
     17 HOST_FROM_OUTSIDE_LAB = HOST + '.cros'
     18 ROUTER_FROM_OUTSIDE_LAB = ROUTER + '.cros'
     19 ATTENUATOR_FROM_OUTSIDE_LAB = ATTENUATOR + '.cros'
     20 TESTER_FROM_OUTSIDE_LAB = TESTER + '.cros'
     21 
     22 
     23 class DnsnameMangerUnittest(unittest.TestCase):
     24     """Check that we're correctly mangling DNS names."""
     25 
     26 
     27     def testRouterNamesCorrect(self):
     28         """Router names should look like <dut_dns_name>-router[.cros]"""
     29         self.assertEquals(ROUTER, dnsname_mangler.get_router_addr(HOST))
     30         self.assertEquals(
     31                 ROUTER_FROM_OUTSIDE_LAB,
     32                 dnsname_mangler.get_router_addr(HOST_FROM_OUTSIDE_LAB))
     33 
     34 
     35     def testAttenuatorNamesCorrect(self):
     36         """Router names should look like <dut_dns_name>-attenuator[.cros]"""
     37         self.assertEquals(ATTENUATOR, dnsname_mangler.get_attenuator_addr(HOST))
     38         self.assertEquals(
     39                 ATTENUATOR_FROM_OUTSIDE_LAB,
     40                 dnsname_mangler.get_attenuator_addr(HOST_FROM_OUTSIDE_LAB))
     41 
     42 
     43     def testTesterNamesCorrect(self):
     44         """Router names should look like <dut_dns_name>-router[.cros]"""
     45         self.assertEquals(TESTER, dnsname_mangler.get_tester_addr(HOST))
     46         self.assertEquals(
     47                 TESTER_FROM_OUTSIDE_LAB,
     48                 dnsname_mangler.get_tester_addr(HOST_FROM_OUTSIDE_LAB))
     49 
     50 
     51 if __name__ == '__main__':
     52     unittest.main()
     53