Skip to content

Commit

Permalink
q-dev: fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
piotrbartman committed Oct 15, 2024
1 parent 6dd8f56 commit 1302bf9
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions qubes/ext/block.py
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ async def on_domain_shutdown(self, vm, event, **_kwargs):
if front_vm == vm:
dev = BlockDevice(vm, dev_id)
asyncio.ensure_future(front_vm.fire_event_async(
'device-detach:block', port=dev))
'device-detach:block', port=dev.port))
else:
new_cache[domain.name][dev_id] = front_vm
self.devices_cache = new_cache.copy()
Expand All @@ -604,7 +604,7 @@ async def _detach_and_notify(self, vm, device, options):
self.on_device_pre_detached_block(
vm, 'device-pre-detach:block', device.port)
await vm.fire_event_async(
'device-detach:block', port=device, options=options)
'device-detach:block', port=device.port, options=options)

@qubes.ext.handler('qubes-close', system=True)
def on_qubes_close(self, app, event):
Expand Down
2 changes: 1 addition & 1 deletion qubes/ext/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def device_list_change(
for dev_id, front_vm in detached.items():
dev = device_class(vm, dev_id)
asyncio.ensure_future(front_vm.fire_event_async(
f'device-detach:{devclass}', port=dev))
f'device-detach:{devclass}', port=dev.port))
for dev_id in removed:
device = device_class(vm, dev_id)
vm.fire_event(f'device-removed:{devclass}', device=device)
Expand Down
6 changes: 3 additions & 3 deletions qubes/tests/devices_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -833,9 +833,9 @@ def test_063_on_qdb_change_changed(self):

self.assertEqual(self.ext.devices_cache, {'sys-usb': {'sda': front_2}})
fire_event_async.assert_called_with(
'device-detach:block', port=exp_dev)
'device-detach:block', port=exp_dev.port)
fire_event_async_2.assert_called_once_with(
'device-attach:block', port=exp_dev, options={})
'device-attach:block', device=exp_dev, options={})

def test_064_on_qdb_change_removed_attached(self):
# attached to front-vm
Expand Down Expand Up @@ -889,7 +889,7 @@ def test_064_on_qdb_change_removed_attached(self):
self.ext.on_qdb_change(back_vm, None, None)
self.assertEqual(self.ext.devices_cache, {'sys-usb': {}})
fire_event_async.assert_called_with(
'device-detach:block', port=exp_dev)
'device-detach:block', port=exp_dev.port)
self.assertEqual(
back_vm.fired_events[
('device-removed:block', frozenset({('device', exp_dev)}))],
Expand Down

0 comments on commit 1302bf9

Please sign in to comment.