Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
piotrbartman committed Jul 16, 2024
1 parent 12ef850 commit 3e5edbf
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions qubesadmin/tests/tools/qvm_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,26 +86,40 @@ def test_001_list_assigned_required(self):
# This shouldn't be listed
self.expected_device_call(
'test-vm2', 'Available',
b"0\0dev2 ident='dev1' devclass='testclass' backend_domain='test-vm2'\n")
self.expected_device_call('test-vm3', 'Available')
b"0\0dev2 ident='dev2' devclass='testclass' backend_domain='test-vm2'\n")
self.expected_device_call(
'test-vm3', 'Available',
b"0\0dev3 ident='dev3' devclass='testclass' backend_domain='test-vm3' vendor='evil inc.' product='test-device-3'\n"
)
self.expected_device_call('test-vm1', 'Attached')
self.expected_device_call('test-vm2', 'Attached')
self.expected_device_call('test-vm3', 'Attached')
self.expected_device_call('test-vm1', 'Assigned')
self.expected_device_call('test-vm2', 'Assigned')
self.expected_device_call(
'test-vm3', 'Assigned',
'test-vm2', 'Assigned',
b"0\0test-vm1+dev1 ident='dev1' devclass='testclass' "
b"backend_domain='test-vm1' attach_automatically='yes' "
b"required='yes' _option='other option' _extra_opt='yes'\n"
b"test-vm3+dev3 ident='dev3' devclass='testclass' "
b"backend_domain='test-vm3' attach_automatically='yes' "
b"required='yes'\n"
)
self.expected_device_call(
'test-vm3', 'Assigned',
b"0\0test-vm1+dev1 ident='dev1' devclass='testclass' "
b"backend_domain='test-vm1' attach_automatically='yes' "
b"required='yes' _option='test option'\n"
)

with qubesadmin.tests.tools.StdoutBuffer() as buf:
qubesadmin.tools.qvm_device.main(
['testclass', 'list', 'test-vm3'], app=self.app)
self.assertEqual(
buf.getvalue(),
'test-vm1:dev1 ?******: itl test-device test-vm3\n'
'test-vm1:dev1 ?******: itl test-device '
'test-vm2 (option=other option, extra_opt=yes), '
'test-vm3 (option=test option)\n'
'test-vm3:dev3 ?******: evil inc. test-device-3 test-vm2\n'
)

def test_002_list_attach(self):
Expand Down

0 comments on commit 3e5edbf

Please sign in to comment.