def _getDevices(self, devices=None): """ Get list of device meta data for available devices. """ raw_args = [] raw_args.extend(["--platform", self.args.platform]) if self.args.platform_sig: raw_args.append("--platform_sig") raw_args.append(self.args.platform_sig) if devices: raw_args.append("--devices") raw_args.append(devices) elif self.args.devices: raw_args.append("--devices") raw_args.append(self.args.devices) if self.args.hash_platform_mapping: # if the user provides filename, we will load it. raw_args.append("--hash_platform_mapping") raw_args.append(self.args.hash_platform_mapping) if self.args.device_name_mapping: # if the user provides filename, we will load it. raw_args.append("--device_name_mapping") raw_args.append(self.args.device_name_mapping) app = GetConnectedDevices(raw_args=raw_args) devices_json = app.run() assert devices_json, "Devices cannot be empty" devices = json.loads(devices_json.strip()) return devices
def test_run(self): config_path = os.path.join(BENCHMARK_DIR, "test/test_config") with patch("get_connected_devices.getPlatforms", return_value=[]) as getPlatforms,\ patch('argparse.ArgumentParser.parse_known_args', return_value=(argparse.Namespace( config_dir=config_path, logger_level='warn', reset_options=None), [])): app = GetConnectedDevices() app.run() getPlatforms.assert_called_once()
def _getDevices(self): raw_args = [] raw_args.extend(["--platform", self.args.platform]) if self.args.platform_sig: raw_args.append("--platform_sig") raw_args.append(self.args.platform_sig) if self.args.devices: raw_args.append("--devices") raw_args.append(self.args.devices) if self.args.hash_platform_mapping: # if the user provides filename, we will load it. raw_args.append("--hash_platform_mapping") raw_args.append(self.args.hash_platform_mapping) app = GetConnectedDevices(raw_args=raw_args) devices_json = app.run() assert devices_json, "Devices cannot be empty" devices = json.loads(devices_json.strip()) return devices