<s> """<STR_LIT>""" <EOL> import mock <EOL> from google . apputils import basetest <EOL> import airport <EOL> class AirportModuleTest ( basetest . TestCase ) : <EOL> """<STR_LIT>""" <EOL> def setUp ( self ) : <EOL> self . mock_getintf_patcher = mock . patch . object ( airport , <EOL> '<STR_LIT>' ) <EOL> self . mock_getintf = self . mock_getintf_patcher . start ( ) <EOL> self . mock_intf = mock . MagicMock ( ) <EOL> self . mock_getintf . return_value = self . mock_intf <EOL> self . mock_sleep_patcher = mock . patch . object ( airport . time , '<STR_LIT>' ) <EOL> self . mock_sleep = self . mock_sleep_patcher . start ( ) <EOL> def tearDown ( self ) : <EOL> self . mock_getintf . stop ( ) <EOL> self . mock_sleep . stop ( ) <EOL> def testSetInterfacePowerOff ( self ) : <EOL> self . mock_intf . setPower_error_ . return_value = ( <NUM_LIT:0> , None ) <EOL> airport . SetInterfacePower ( False ) <EOL> self . mock_intf . setPower_error_ . assert_called_once_with ( False , None ) <EOL> def testDisassociate ( self ) : <EOL> airport . Disassociate ( ) <EOL> self . mock_intf . disassociate . assert_called_once_with ( ) <EOL> def testAssociateToNetworkNoPassword ( self ) : <EOL> mock_network = mock . MagicMock ( ) <EOL> self . mock_intf . associateToNetwork_password_forceBSSID_remember_error_ . return_value = [ True , None ] <EOL> mock_network . ssid . return_value = '<STR_LIT>' <EOL> self . mock_intf . ssid . return_value = '<STR_LIT>' <EOL> airport . AssociateToNetwork ( mock_network ) <EOL> self . mock_intf . associateToNetwork_password_forceBSSID_remember_error_ . assert_called_once_with ( <EOL> mock_network , None , False , False , None ) <EOL> def testAssociateToNetworkPassword ( self ) : <EOL> mock_network = mock . MagicMock ( ) <EOL> self . mock_intf . associateToNetwork_password_forceBSSID_remember_error_ . return_value = [ True , None ] <EOL> mock_network . ssid . return_value = '<STR_LIT>' <EOL> self . mock_intf . ssid . return_value = '<STR_LIT>' <EOL> airport . AssociateToNetwork ( mock_network , '<STR_LIT>' ) <EOL> self . mock_intf . associateToNetwork_password_forceBSSID_remember_error_ . assert_called_once_with ( <EOL> mock_network , '<STR_LIT>' , False , False , None ) <EOL> @ mock . patch . object ( airport , '<STR_LIT>' ) <EOL> def testAssociateToSSIDNoPassword ( self , mock_sfn ) : <EOL> mock_network = mock . MagicMock ( ) <EOL> mock_sfn . return_value = { '<STR_LIT>' : mock_network } <EOL> self . mock_intf . associateToNetwork_password_forceBSSID_remember_error_ . return_value = [ True , None ] <EOL> mock_network . ssid . return_value = '<STR_LIT>' <EOL> self . mock_intf . ssid . return_value = '<STR_LIT>' <EOL> airport . AssociateToSSID ( '<STR_LIT>' ) <EOL> mock_sfn . assert_called_once_with ( '<STR_LIT>' , interface = self . mock_intf ) <EOL> self . mock_intf . associateToNetwork_password_forceBSSID_remember_error_ . assert_called_once_with ( <EOL> mock_network , None , False , False , None ) <EOL> @ mock . patch . object ( airport , '<STR_LIT>' ) <EOL> def testAssociateToSSIDPassword ( self , mock_sfn ) : <EOL> mock_network = mock . MagicMock ( ) <EOL> mock_sfn . return_value = { '<STR_LIT>' : mock_network } <EOL> self . mock_intf . associateToNetwork_password_forceBSSID_remember_error_ . return_value = [ True , None ] <EOL> mock_network . ssid . return_value = '<STR_LIT>' <EOL> self . mock_intf . ssid . return_value = '<STR_LIT>' <EOL> airport . AssociateToSSID ( '<STR_LIT>' , password = '<STR_LIT>' ) <EOL> mock_sfn . assert_called_once_with ( '<STR_LIT>' , interface = self . mock_intf ) <EOL> self . mock_intf . associateToNetwork_password_forceBSSID_remember_error_ . assert_called_once_with ( <EOL> mock_network , '<STR_LIT>' , False , False , None ) <EOL> def testScanForNetworksNoSSID ( self ) : <EOL> mock_network = mock . MagicMock ( ) <EOL> mock_network . ssid . return_value = '<STR_LIT>' <EOL> mock_network . rssiValue . return_value = - <NUM_LIT> <EOL> mock_network2 = mock . MagicMock ( ) <EOL> mock_network2 . ssid . return_value = '<STR_LIT>' <EOL> mock_network2 . rssiValue . return_value = - <NUM_LIT> <EOL> mock_network3 = mock . MagicMock ( ) <EOL> mock_network3 . ssid . return_value = '<STR_LIT>' <EOL> mock_network3 . rssiValue . return_value = - <NUM_LIT> <EOL> networks = [ mock_network , mock_network2 , mock_network3 ] <EOL> self . mock_intf . scanForNetworksWithName_error_ . return_value = [ <EOL> networks , None ] <EOL> retval = airport . ScanForNetworks ( None ) <EOL> self . mock_intf . scanForNetworksWithName_error_ . assert_called_once_with ( None , <EOL> None ) <EOL> self . assertEqual ( retval , { '<STR_LIT>' : mock_network2 , <EOL> '<STR_LIT>' : mock_network3 } ) <EOL> def main ( unused_argv ) : <EOL> basetest . main ( ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> basetest . main ( ) </s>
