Skip to content

Commit

Permalink
fixup! tests/usb: Test the USB portal via pytest, dbusmock and umockdev
Browse files Browse the repository at this point in the history
  • Loading branch information
swick committed Oct 17, 2024
1 parent 0955548 commit 8ac148d
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 5 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ RUN apt install -y --no-install-recommends \
python3-pytest \
python3-pytest-xdist \
python3-dbusmock \
python3-dbus
python3-dbus \
umockdev

# Install doc dependencies
RUN apt install -y --no-install-recommends \
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/container.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
env:
IMAGE_TAG: 20241015-2
IMAGE_TAG: 20241017-0

on:
workflow_call:
Expand Down
1 change: 1 addition & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ libportal_dep = dependency('libportal',
pipewire_dep = dependency('libpipewire-0.3', version: '>= 0.2.90')
libsystemd_dep = dependency('libsystemd', required: get_option('systemd'))
gudev_dep = dependency('gudev-1.0', required: get_option('gudev'))
umockdev_dep = dependency('umockdev-1.0')


bwrap = find_program('bwrap', required: get_option('sandboxed-image-validation'))
Expand Down
6 changes: 5 additions & 1 deletion tests/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,11 @@ python = pymod.find_installation(
required: get_option('pytest'),
)

enable_pytest = pytest.found() and python.found() and python.language_version().version_compare('>=3.9')
enable_pytest = \
pytest.found() and \
python.found() and \
python.language_version().version_compare('>=3.9') and \
umockdev_dep.found()

if enable_pytest
subdir('templates')
Expand Down
10 changes: 8 additions & 2 deletions tests/test_usb.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,17 +290,23 @@ def test_acquire(self, portal_mock, app_id):
"00001",
)

possible_vendors = ["04a9", "04aa"]

usb_intf = portal_mock.get_dbus_interface()
devices = usb_intf.EnumerateDevices({})
assert len(devices) == 2
(id1, dev_info1) = devices[0]
assert id1
assert dev_info1
assert dev_info1["properties"]["ID_VENDOR_ID"] == "04a9"
vendor_id = dev_info1["properties"]["ID_VENDOR_ID"]
assert vendor_id in possible_vendors
possible_vendors.remove(vendor_id)
(id2, dev_info2) = devices[1]
assert id2
assert dev_info2
assert dev_info2["properties"]["ID_VENDOR_ID"] == "04aa"
vendor_id = dev_info2["properties"]["ID_VENDOR_ID"]
assert vendor_id in possible_vendors
possible_vendors.remove(vendor_id)

request = portal_mock.create_request()
response = request.call(
Expand Down

0 comments on commit 8ac148d

Please sign in to comment.