devices = Device.query.options(db.load_only(Device.id)).all()
pdb.set_trace()
for device in devices:
# get all configs for this device
configs = Config.query.filter(Config.device_id == device.id).order_by(Config.first_seen).all()
if not configs: continue
configs = {config.id: config for config in configs}
config_ids = list(configs.keys())
last_config_id = config_ids[0]
for config_id in config_ids[1:]:
if _is_same_config(configs[last_config_id].config, configs[config_id].config):
使用mocker.patch device_query = mocker.patch('devicedb.classes.Device.query')我可以模拟设备。但是之后,我无法在为配置编写模拟时模拟配置。一个请帮助我解决这个问题。
device_query = mocker.patch('devicedb.classes.Device.query')
device_query.return_value.options.return_value.all.return_value = Device(id=123)
config_query = mocker.patch('devicedb.classes.Config.query')