Skip to content

Commit

Permalink
q-dev: fix tests and pylint
Browse files Browse the repository at this point in the history
  • Loading branch information
piotrbartman committed Oct 29, 2024
1 parent a627696 commit 250fc05
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
2 changes: 2 additions & 0 deletions qubesadmin/device_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -862,6 +862,7 @@ class DeviceInfo(VirtualDevice):
def __init__(
self,
port: Port,
*,
vendor: Optional[str] = None,
product: Optional[str] = None,
manufacturer: Optional[str] = None,
Expand Down Expand Up @@ -1225,6 +1226,7 @@ def new(
port_id: str,
devclass: str,
device_id: Optional[str] = None,
*,
frontend_domain: Optional[QubesVM] = None,
options=None,
mode: Union[str, AssignmentMode] = "manual",
Expand Down
8 changes: 4 additions & 4 deletions qubesadmin/tests/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -736,15 +736,15 @@ def test_043_clone_devices(self):
self.app.expected_calls[
('test-vm', 'admin.vm.device.pci.Assigned', None, None)] = \
(b"0\0test-vm2+dev1 port_id='dev1' devclass='pci' "
b"backend_domain='test-vm2' mode='auto-attach' "
b"backend_domain='test-vm2' mode='required' "
b"_ro='yes'\n"
b"test-vm3+dev2 port_id='dev2' devclass='pci' "
b"backend_domain='test-vm3' mode='required'\n")

self.app.expected_calls[
('new-name', 'admin.vm.device.pci.Assign', 'test-vm2+dev1:*',
b"device_id='*' port_id='dev1' "
b"devclass='pci' backend_domain='test-vm2' mode='auto-attach' "
b"devclass='pci' backend_domain='test-vm2' mode='required' "
b"frontend_domain='new-name' _ro='yes'")] = b'0\0'

self.app.expected_calls[
Expand Down Expand Up @@ -783,15 +783,15 @@ def test_044_clone_devices_fail(self):
self.app.expected_calls[
('test-vm', 'admin.vm.device.pci.Assigned', None, None)] = \
(b"0\0test-vm2+dev1 port_id='dev1' devclass='pci' "
b"backend_domain='test-vm2' mode='auto-attach' "
b"backend_domain='test-vm2' mode='required' "
b"_ro='yes'\n"
b"test-vm3+dev2 port_id='dev2' devclass='pci' "
b"backend_domain='test-vm3' mode='required'\n")

self.app.expected_calls[
('new-name', 'admin.vm.device.pci.Assign', 'test-vm2+dev1:*',
b"device_id='*' port_id='dev1' "
b"devclass='pci' backend_domain='test-vm2' mode='auto-attach' "
b"devclass='pci' backend_domain='test-vm2' mode='required' "
b"frontend_domain='new-name' _ro='yes'")] = b'0\0'

self.app.expected_calls[
Expand Down
9 changes: 8 additions & 1 deletion qubesadmin/tests/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
import subprocess
import qubesadmin.tests
import unittest

from qubesadmin.device_protocol import VirtualDevice, Port

try:
# qubesadmin.events require python3, so this tests can also use python3 features
import asyncio
Expand Down Expand Up @@ -257,8 +260,12 @@ def test_030_events_device(self):
handler = unittest.mock.Mock()
self.dispatcher.add_handler('device-attach:test', handler)
self.dispatcher.handle('test-vm', 'device-attach:test',
device='test-vm2:dev', options='{}')
device='test-vm2:dev:id', options='{}')
vm = self.app.domains.get_blind('test-vm')
self.app.domains.get_blind('test-vm2').devices = {
'test': {'dev': VirtualDevice(
Port(self.app.domains.get_blind('test-vm2'),"dev", "test"),
device_id="id")}}
dev = self.app.domains.get_blind('test-vm2').devices['test']['dev']
handler.assert_called_once_with(vm, 'device-attach:test', device=dev,
options='{}')

0 comments on commit 250fc05

Please sign in to comment.