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 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' 15TESTER = 'chromeos1-row1-rack1-host1-router' 16 17HOST_FROM_OUTSIDE_LAB = HOST + '.cros' 18ROUTER_FROM_OUTSIDE_LAB = ROUTER + '.cros' 19ATTENUATOR_FROM_OUTSIDE_LAB = ATTENUATOR + '.cros' 20TESTER_FROM_OUTSIDE_LAB = TESTER + '.cros' 21 22 23class 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 51if __name__ == '__main__': 52 unittest.main() 53