Skip to content

Commit

Permalink
q-dev: update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
piotrbartman committed Jun 12, 2024
1 parent d430f7f commit eae86a6
Show file tree
Hide file tree
Showing 4 changed files with 287 additions and 132 deletions.
8 changes: 1 addition & 7 deletions qubes/devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,6 @@
from qubes.api import ProtocolError


class DeviceNotAttached(qubes.exc.QubesException, KeyError):
"""
Trying to detach not attached device.
"""


class DeviceNotAssigned(qubes.exc.QubesException, KeyError):
"""
Trying to unassign not assigned device.
Expand Down Expand Up @@ -1115,7 +1109,7 @@ async def update_assignment(
await self._vm.fire_event_async(
'device-assignment-changed:' + self._bus, device=device)
else:
await self.detach(assignment)
await self.unassign(assignment)

async def detach(self, device: Device):
"""
Expand Down
2 changes: 1 addition & 1 deletion qubes/tests/api_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -1910,7 +1910,7 @@ def test_491_vm_device_detach_not_attached(self):
self.vm.add_handler('device-detach:testclass', mock_detach)
with unittest.mock.patch.object(qubes.vm.qubesvm.QubesVM,
'is_halted', lambda _: False):
with self.assertRaises(qubes.devices.DeviceNotAttached):
with self.assertRaises(qubes.devices.DeviceNotAssigned):
self.call_mgmt_func(b'admin.vm.device.testclass.Detach',
b'test-vm1', b'test-vm1+1234')
self.assertFalse(mock_detach.called)
Expand Down
Loading

0 comments on commit eae86a6

Please sign in to comment.