def testFoundOneFuchsiaDevice(self): with mock.patch('os.path.exists', return_value=True): with mock.patch(_FUCHSIA_DEVICE_IMPORT_PATH + '._FindFuchsiaDevice', return_value='host0 target0'): found_devices = fuchsia_device.FindAllAvailableDevices( self._options) self.assertEquals(len(found_devices), 1) device = found_devices[0] self.assertEquals(device.host, 'host0') self.assertEquals(device.target_name, 'target0')
def testSkipSDKUseIfSshPortExists(self): self._options.fuchsia_ssh_port = 22222 with mock.patch(_FUCHSIA_DEVICE_IMPORT_PATH + '._DownloadFuchsiaSDK') as get_mock: found_devices = fuchsia_device.FindAllAvailableDevices( self._options) get_mock.assert_not_called() self.assertEquals(len(found_devices), 1) device = found_devices[0] self.assertEquals(device.port, 22222) self.assertEquals(device.host, 'localhost')
def testDownloadSDKIfNotExists(self): with mock.patch('os.path.exists', return_value=False): with mock.patch(_FUCHSIA_DEVICE_IMPORT_PATH + '._DownloadFuchsiaSDK') as get_mock: with mock.patch(_FUCHSIA_DEVICE_IMPORT_PATH + '._FindFuchsiaDevice', return_value=None) as find_mock: self.assertEquals( fuchsia_device.FindAllAvailableDevices(self._options), []) self.assertEquals(get_mock.call_count, 1) self.assertEquals(find_mock.call_count, 1)
def testSkipDownloadSDKIfExistsInChromium(self): with mock.patch('os.path.exists', return_value=True): with mock.patch(_FUCHSIA_DEVICE_IMPORT_PATH + '._DownloadFuchsiaSDK') as get_mock: with mock.patch(_FUCHSIA_DEVICE_IMPORT_PATH + '._FindFuchsiaDevice', return_value=None) as find_mock: self.assertEquals( fuchsia_device.FindAllAvailableDevices(self._options), []) get_mock.assert_not_called() self.assertEquals(find_mock.call_count, 1)
def testSkipUsingSDKIfFuchsiaHostFlagUsed(self): with mock.patch(_FUCHSIA_DEVICE_IMPORT_PATH + '._DownloadFuchsiaSDK') as get_mock: with mock.patch(_FUCHSIA_DEVICE_IMPORT_PATH + '._FindFuchsiaDevice', return_value=None) as find_mock: self._options.fuchsia_device_address = 'fuchsia_device' found_devices = fuchsia_device.FindAllAvailableDevices( self._options) self.assertEquals(len(found_devices), 1) device = found_devices[0] self.assertEquals(device.host, 'fuchsia_device') self.assertEquals(device.target_name, 'device_target') get_mock.assert_not_called() find_mock.assert_not_called()
def testSkipDownloadSDKIfExistsInCatapult(self): def side_effect(path): if path == fuchsia_device._SDK_ROOT_IN_CHROMIUM: return True if path == fuchsia_device._SDK_ROOT_IN_CATAPULT: return False raise RuntimeError('Invalid path to Fuchsia SDK') with mock.patch('os.path.exists') as path_mock: with mock.patch(_FUCHSIA_DEVICE_IMPORT_PATH + '._DownloadFuchsiaSDK') as get_mock: with mock.patch(_FUCHSIA_DEVICE_IMPORT_PATH + '._FindFuchsiaDevice', return_value=None) as find_mock: path_mock.side_effect = side_effect self.assertEquals( fuchsia_device.FindAllAvailableDevices(self._options), []) self.assertEquals(get_mock.call_count, 0) self.assertEquals(find_mock.call_count, 1)
def testFindAllAvailableDevicesFailsNonLinuxHost(self): options = browser_options.BrowserFinderOptions( fuchsia_interface.FUCHSIA_BROWSERS[0]) with mock.patch('platform.system', return_value='not_Linux'): self.assertEquals(fuchsia_device.FindAllAvailableDevices(options), [])
def testFindAllAvailableDevicesFailsNonFuchsiaBrowser(self): options = browser_options.BrowserFinderOptions('not_fuchsia_browser') self.assertEquals(fuchsia_device.FindAllAvailableDevices(options), [])