1#!/usr/bin/python 2# Copyright (c) 2013 The Chromium OS Authors. All rights reserved. 3# Use of this source code is governed by a BSD-style license that can be 4# found in the LICENSE file. 5 6import logging 7import mock 8import sys 9import unittest 10 11# Import common to set the path to find autotest_lib 12import common 13from autotest_lib.client.bin import utils 14utils.system = mock.MagicMock() 15 16from autotest_lib.client.cros.cellular import ether_io_rf_switch 17ether_io_rf_switch.RfSwitch = mock.MagicMock() 18 19# Mock the local modem 20sys.modules['flimflam'] = mock.MagicMock() 21 22from autotest_lib.client.cros.cellular import labconfig 23config = labconfig.Configuration(['--cell', 'mtv', '--technology', 'CDMA']) 24# Mock out the get_interface_ip and have it return a real DUT. 25# otherwise is looks up the IP of this machine and tries to find it 26# in the DUTs section of the lab config. Not useful if this test file 27# is run on a workstation. 28dut1_ip = config.cell['duts'][0]['address'] 29 30labconfig.get_interface_ip = mock.Mock(return_value = dut1_ip) 31 32# Must import after the mocks. 33import environment 34import cellular_logging 35log = cellular_logging.SetupCellularLogging('environment_test') 36 37 38class EnvTest(unittest.TestCase): 39 40 def test_Env3G(self): 41 """ 42 make an environment 43 """ 44 with environment.DefaultCellularTestContext(config) as c: 45 env = c.env 46 env.StartDefault('Technology:HSDPA') 47 48 def test_EnvLte(self): 49 """ 50 make an environment 51 """ 52 log.debug('LTE Enviroment test') 53 with environment.DefaultCellularTestContext(config) as c: 54 env = c.env 55 env.StartDefault('Technology:LTE') 56 57if __name__ == '__main__': 58 unittest.main() 59