python-dbusmock 0.31.1__tar.gz → 0.32.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {python-dbusmock-0.31.1 → python-dbusmock-0.32.1}/.github/workflows/release.yml +1 -1
- {python-dbusmock-0.31.1 → python-dbusmock-0.32.1}/.github/workflows/tests.yml +9 -1
- {python-dbusmock-0.31.1 → python-dbusmock-0.32.1}/PKG-INFO +1 -1
- {python-dbusmock-0.31.1 → python-dbusmock-0.32.1}/dbusmock/__main__.py +6 -2
- {python-dbusmock-0.31.1 → python-dbusmock-0.32.1}/dbusmock/_version.py +1 -1
- {python-dbusmock-0.31.1 → python-dbusmock-0.32.1}/dbusmock/templates/bluez5.py +210 -1
- {python-dbusmock-0.31.1 → python-dbusmock-0.32.1}/dbusmock/templates/gnome_screensaver.py +6 -2
- python-dbusmock-0.32.1/dbusmock/templates/modemmanager.py +209 -0
- {python-dbusmock-0.31.1 → python-dbusmock-0.32.1}/dbusmock/templates/networkmanager.py +7 -7
- {python-dbusmock-0.31.1 → python-dbusmock-0.32.1}/packaging/python-dbusmock.spec +1 -1
- {python-dbusmock-0.31.1 → python-dbusmock-0.32.1}/packit.yaml +4 -2
- {python-dbusmock-0.31.1 → python-dbusmock-0.32.1}/python_dbusmock.egg-info/PKG-INFO +1 -1
- {python-dbusmock-0.31.1 → python-dbusmock-0.32.1}/python_dbusmock.egg-info/SOURCES.txt +2 -0
- {python-dbusmock-0.31.1 → python-dbusmock-0.32.1}/tests/run-centos +5 -2
- {python-dbusmock-0.31.1 → python-dbusmock-0.32.1}/tests/run-debian +8 -9
- {python-dbusmock-0.31.1 → python-dbusmock-0.32.1}/tests/run-fedora +5 -2
- {python-dbusmock-0.31.1 → python-dbusmock-0.32.1}/tests/run-ubuntu +8 -9
- python-dbusmock-0.32.1/tests/test_bluez5.py +618 -0
- {python-dbusmock-0.31.1 → python-dbusmock-0.32.1}/tests/test_code.py +1 -0
- python-dbusmock-0.32.1/tests/test_modemmanager.py +144 -0
- {python-dbusmock-0.31.1 → python-dbusmock-0.32.1}/tests/test_power_profiles_daemon.py +3 -3
- python-dbusmock-0.31.1/tests/test_bluez5.py +0 -299
- {python-dbusmock-0.31.1 → python-dbusmock-0.32.1}/.fmf/version +0 -0
- {python-dbusmock-0.31.1 → python-dbusmock-0.32.1}/.github/release.eloquent.yml +0 -0
- {python-dbusmock-0.31.1 → python-dbusmock-0.32.1}/.github/workflows/pages.yml +0 -0
- {python-dbusmock-0.31.1 → python-dbusmock-0.32.1}/.gitignore +0 -0
- {python-dbusmock-0.31.1 → python-dbusmock-0.32.1}/.pre-commit-config.yaml +0 -0
- {python-dbusmock-0.31.1 → python-dbusmock-0.32.1}/COPYING +0 -0
- {python-dbusmock-0.31.1 → python-dbusmock-0.32.1}/NEWS +0 -0
- {python-dbusmock-0.31.1 → python-dbusmock-0.32.1}/README.md +0 -0
- {python-dbusmock-0.31.1 → python-dbusmock-0.32.1}/dbusmock/__init__.py +0 -0
- {python-dbusmock-0.31.1 → python-dbusmock-0.32.1}/dbusmock/mockobject.py +0 -0
- {python-dbusmock-0.31.1 → python-dbusmock-0.32.1}/dbusmock/pytest_fixtures.py +0 -0
- {python-dbusmock-0.31.1 → python-dbusmock-0.32.1}/dbusmock/templates/SKELETON +0 -0
- {python-dbusmock-0.31.1 → python-dbusmock-0.32.1}/dbusmock/templates/__init__.py +0 -0
- {python-dbusmock-0.31.1 → python-dbusmock-0.32.1}/dbusmock/templates/bluez5-obex.py +0 -0
- {python-dbusmock-0.31.1 → python-dbusmock-0.32.1}/dbusmock/templates/iio-sensors-proxy.py +0 -0
- {python-dbusmock-0.31.1 → python-dbusmock-0.32.1}/dbusmock/templates/logind.py +0 -0
- {python-dbusmock-0.31.1 → python-dbusmock-0.32.1}/dbusmock/templates/low_memory_monitor.py +0 -0
- {python-dbusmock-0.31.1 → python-dbusmock-0.32.1}/dbusmock/templates/notification_daemon.py +0 -0
- {python-dbusmock-0.31.1 → python-dbusmock-0.32.1}/dbusmock/templates/ofono.py +0 -0
- {python-dbusmock-0.31.1 → python-dbusmock-0.32.1}/dbusmock/templates/polkitd.py +0 -0
- {python-dbusmock-0.31.1 → python-dbusmock-0.32.1}/dbusmock/templates/power_profiles_daemon.py +0 -0
- {python-dbusmock-0.31.1 → python-dbusmock-0.32.1}/dbusmock/templates/systemd.py +0 -0
- {python-dbusmock-0.31.1 → python-dbusmock-0.32.1}/dbusmock/templates/timedated.py +0 -0
- {python-dbusmock-0.31.1 → python-dbusmock-0.32.1}/dbusmock/templates/upower.py +0 -0
- {python-dbusmock-0.31.1 → python-dbusmock-0.32.1}/dbusmock/templates/upower_power_profiles_daemon.py +0 -0
- {python-dbusmock-0.31.1 → python-dbusmock-0.32.1}/dbusmock/templates/urfkill.py +0 -0
- {python-dbusmock-0.31.1 → python-dbusmock-0.32.1}/dbusmock/testcase.py +0 -0
- {python-dbusmock-0.31.1 → python-dbusmock-0.32.1}/doc/conf.py +0 -0
- {python-dbusmock-0.31.1 → python-dbusmock-0.32.1}/doc/index.rst +0 -0
- {python-dbusmock-0.31.1 → python-dbusmock-0.32.1}/plans/all.fmf +0 -0
- {python-dbusmock-0.31.1 → python-dbusmock-0.32.1}/pyproject.toml +0 -0
- {python-dbusmock-0.31.1 → python-dbusmock-0.32.1}/python_dbusmock.egg-info/dependency_links.txt +0 -0
- {python-dbusmock-0.31.1 → python-dbusmock-0.32.1}/python_dbusmock.egg-info/requires.txt +0 -0
- {python-dbusmock-0.31.1 → python-dbusmock-0.32.1}/python_dbusmock.egg-info/top_level.txt +0 -0
- {python-dbusmock-0.31.1 → python-dbusmock-0.32.1}/setup.cfg +0 -0
- {python-dbusmock-0.31.1 → python-dbusmock-0.32.1}/setup.py +0 -0
- {python-dbusmock-0.31.1 → python-dbusmock-0.32.1}/tests/__init__.py +0 -0
- {python-dbusmock-0.31.1 → python-dbusmock-0.32.1}/tests/conftest.py +0 -0
- {python-dbusmock-0.31.1 → python-dbusmock-0.32.1}/tests/main.fmf +0 -0
- {python-dbusmock-0.31.1 → python-dbusmock-0.32.1}/tests/run +0 -0
- {python-dbusmock-0.31.1 → python-dbusmock-0.32.1}/tests/test_api.py +0 -0
- {python-dbusmock-0.31.1 → python-dbusmock-0.32.1}/tests/test_api_pytest.py +0 -0
- {python-dbusmock-0.31.1 → python-dbusmock-0.32.1}/tests/test_cli.py +0 -0
- {python-dbusmock-0.31.1 → python-dbusmock-0.32.1}/tests/test_gnome_screensaver.py +0 -0
- {python-dbusmock-0.31.1 → python-dbusmock-0.32.1}/tests/test_iio_sensors_proxy.py +0 -0
- {python-dbusmock-0.31.1 → python-dbusmock-0.32.1}/tests/test_logind.py +0 -0
- {python-dbusmock-0.31.1 → python-dbusmock-0.32.1}/tests/test_low_memory_monitor.py +0 -0
- {python-dbusmock-0.31.1 → python-dbusmock-0.32.1}/tests/test_networkmanager.py +0 -0
- {python-dbusmock-0.31.1 → python-dbusmock-0.32.1}/tests/test_notification_daemon.py +0 -0
- {python-dbusmock-0.31.1 → python-dbusmock-0.32.1}/tests/test_ofono.py +0 -0
- {python-dbusmock-0.31.1 → python-dbusmock-0.32.1}/tests/test_polkitd.py +0 -0
- {python-dbusmock-0.31.1 → python-dbusmock-0.32.1}/tests/test_systemd.py +0 -0
- {python-dbusmock-0.31.1 → python-dbusmock-0.32.1}/tests/test_timedated.py +0 -0
- {python-dbusmock-0.31.1 → python-dbusmock-0.32.1}/tests/test_upower.py +0 -0
- {python-dbusmock-0.31.1 → python-dbusmock-0.32.1}/tests/test_urfkill.py +0 -0
|
@@ -45,7 +45,7 @@ jobs:
|
|
|
45
45
|
rm -rf tmp
|
|
46
46
|
|
|
47
47
|
- name: Create GitHub release
|
|
48
|
-
uses: cockpit-project/action-release@
|
|
48
|
+
uses: cockpit-project/action-release@7d2e2657382e8d34f88a24b5987f2b81ea165785
|
|
49
49
|
with:
|
|
50
50
|
filename: "dist/python-dbusmock-${{ github.ref_name }}.tar.gz"
|
|
51
51
|
|
|
@@ -17,8 +17,8 @@ jobs:
|
|
|
17
17
|
- docker.io/ubuntu:latest
|
|
18
18
|
- registry.fedoraproject.org/fedora:latest
|
|
19
19
|
- registry.fedoraproject.org/fedora:rawhide
|
|
20
|
-
- quay.io/centos/centos:stream8
|
|
21
20
|
- quay.io/centos/centos:stream9
|
|
21
|
+
- quay.io/centos/centos:stream10-development
|
|
22
22
|
|
|
23
23
|
timeout-minutes: 30
|
|
24
24
|
steps:
|
|
@@ -28,6 +28,14 @@ jobs:
|
|
|
28
28
|
# need this to also fetch tags
|
|
29
29
|
fetch-depth: 0
|
|
30
30
|
|
|
31
|
+
- name: Workaround for https://github.com/actions/checkout/pull/697
|
|
32
|
+
run: |
|
|
33
|
+
set -ex
|
|
34
|
+
TAG=$(git describe --tags)
|
|
35
|
+
if echo "$TAG" | grep -q '^[0-9.]\+$'; then
|
|
36
|
+
git fetch --force origin $TAG:refs/tags/$TAG
|
|
37
|
+
fi
|
|
38
|
+
|
|
31
39
|
- name: Run unit tests
|
|
32
40
|
run: |
|
|
33
41
|
dpkg -s podman docker || true
|
|
@@ -16,6 +16,7 @@ __copyright__ = """
|
|
|
16
16
|
import argparse
|
|
17
17
|
import json
|
|
18
18
|
import os
|
|
19
|
+
import platform
|
|
19
20
|
import subprocess
|
|
20
21
|
import sys
|
|
21
22
|
|
|
@@ -51,7 +52,7 @@ def parse_args():
|
|
|
51
52
|
help="template to load (instead of specifying name, path, interface)",
|
|
52
53
|
)
|
|
53
54
|
parser.add_argument(
|
|
54
|
-
"name",
|
|
55
|
+
"name",
|
|
55
56
|
metavar="NAME",
|
|
56
57
|
nargs="?",
|
|
57
58
|
help='D-Bus name to claim (e. g. "com.example.MyService") (if not using -t)',
|
|
@@ -160,7 +161,10 @@ if __name__ == "__main__":
|
|
|
160
161
|
if args.template:
|
|
161
162
|
main_object.AddTemplate(args.template, parameters)
|
|
162
163
|
|
|
163
|
-
|
|
164
|
+
if platform.system() == "Darwin":
|
|
165
|
+
libglib = ctypes.cdll.LoadLibrary("libglib-2.0.dylib")
|
|
166
|
+
else:
|
|
167
|
+
libglib = ctypes.cdll.LoadLibrary("libglib-2.0.so.0")
|
|
164
168
|
|
|
165
169
|
dbusmock.mockobject.objects[args.path] = main_object
|
|
166
170
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
'''auto-generated version from setuptools_scm'''
|
|
2
|
-
__version__ = "0.
|
|
2
|
+
__version__ = "0.32.1"
|
|
@@ -38,9 +38,17 @@ MEDIA_IFACE = "org.bluez.Media1"
|
|
|
38
38
|
NETWORK_SERVER_IFACE = "org.bluez.Network1"
|
|
39
39
|
DEVICE_IFACE = "org.bluez.Device1"
|
|
40
40
|
|
|
41
|
+
LE_ADVERTISING_MANAGER_IFACE = "org.bluez.LEAdvertisingManager1"
|
|
42
|
+
LE_ADVERTISEMENT_IFACE = "org.bluez.LEAdvertisement1"
|
|
43
|
+
ADVERTISEMENT_MONITOR_MANAGER_IFACE = "org.bluez.AdvertisementMonitorManager1"
|
|
44
|
+
ADVERTISEMENT_MONITOR_IFACE = "org.bluez.AdvertisementMonitor1"
|
|
45
|
+
|
|
41
46
|
# The device class of some arbitrary Android phone.
|
|
42
47
|
MOCK_PHONE_CLASS = 5898764
|
|
43
48
|
|
|
49
|
+
# Maximum number of BLE advertisements supported per adapter.
|
|
50
|
+
MAX_ADVERTISEMENT_INSTANCES = 5
|
|
51
|
+
|
|
44
52
|
|
|
45
53
|
@dbus.service.method(AGENT_MANAGER_IFACE, in_signature="os", out_signature="")
|
|
46
54
|
def RegisterAgent(manager, agent_path, capability):
|
|
@@ -48,9 +56,13 @@ def RegisterAgent(manager, agent_path, capability):
|
|
|
48
56
|
|
|
49
57
|
if agent_path in manager.agent_paths:
|
|
50
58
|
raise dbus.exceptions.DBusException(
|
|
51
|
-
"Another agent is already registered " +
|
|
59
|
+
"Another agent is already registered " + agent_path, name="org.bluez.Error.AlreadyExists"
|
|
52
60
|
)
|
|
53
61
|
|
|
62
|
+
# Fallback to "KeyboardDisplay" as per BlueZ spec
|
|
63
|
+
if not capability:
|
|
64
|
+
capability = "KeyboardDisplay"
|
|
65
|
+
|
|
54
66
|
if capability not in all_caps:
|
|
55
67
|
raise dbus.exceptions.DBusException(
|
|
56
68
|
"Unsupported capability " + capability, name="org.bluez.Error.InvalidArguments"
|
|
@@ -107,6 +119,11 @@ def load(mock, _parameters):
|
|
|
107
119
|
bluez.capabilities = {}
|
|
108
120
|
bluez.default_agent = None
|
|
109
121
|
|
|
122
|
+
# whether to expose the LEAdvertisingManager1 interface on adapters (BLE advertising)
|
|
123
|
+
bluez.enable_advertise_api = _parameters.get("enable_advertise_api", True)
|
|
124
|
+
# whether to expose the AdvertisementMonitorManager1 interface on adapters (Passive scanning)
|
|
125
|
+
bluez.enable_monitor_api = _parameters.get("enable_monitor_api", True)
|
|
126
|
+
|
|
110
127
|
|
|
111
128
|
@dbus.service.method(ADAPTER_IFACE, in_signature="o", out_signature="")
|
|
112
129
|
def RemoveDevice(adapter, path):
|
|
@@ -221,6 +238,7 @@ def AddAdapter(self, device_name, system_name):
|
|
|
221
238
|
"Class": dbus.UInt32(268, variant_level=1), # Computer, Laptop
|
|
222
239
|
"DiscoverableTimeout": dbus.UInt32(180, variant_level=1),
|
|
223
240
|
"PairableTimeout": dbus.UInt32(0, variant_level=1),
|
|
241
|
+
"Roles": dbus.Array(["central", "peripheral"], variant_level=1),
|
|
224
242
|
}
|
|
225
243
|
|
|
226
244
|
self.AddObject(
|
|
@@ -253,6 +271,63 @@ def AddAdapter(self, device_name, system_name):
|
|
|
253
271
|
],
|
|
254
272
|
)
|
|
255
273
|
|
|
274
|
+
bluez = mockobject.objects["/org/bluez"]
|
|
275
|
+
|
|
276
|
+
# Advertising Manager
|
|
277
|
+
if bluez.enable_advertise_api:
|
|
278
|
+
# Example values below from an Intel AX200 adapter
|
|
279
|
+
advertising_manager_properties = {
|
|
280
|
+
"ActiveInstances": dbus.Byte(0, variant_level=1),
|
|
281
|
+
"SupportedInstances": dbus.Byte(MAX_ADVERTISEMENT_INSTANCES, variant_level=1),
|
|
282
|
+
"SupportedIncludes": dbus.Array(["tx-power", "appearance", "local-name", "rssi"], variant_level=1),
|
|
283
|
+
"SupportedSecondaryChannels": dbus.Array(["1M", "2M", "Coded"], variant_level=1),
|
|
284
|
+
"SupportedCapabilities": dbus.Dictionary(
|
|
285
|
+
{
|
|
286
|
+
"MaxAdvLen": dbus.Byte(251),
|
|
287
|
+
"MaxScnRspLen": dbus.Byte(251),
|
|
288
|
+
"MinTxPower": dbus.Int16(-34),
|
|
289
|
+
"MaxTxPower": dbus.Int16(7),
|
|
290
|
+
},
|
|
291
|
+
signature="sv",
|
|
292
|
+
variant_level=1,
|
|
293
|
+
),
|
|
294
|
+
"SupportedFeatures": dbus.Array(
|
|
295
|
+
[
|
|
296
|
+
"CanSetTxPower",
|
|
297
|
+
"HardwareOffload",
|
|
298
|
+
],
|
|
299
|
+
variant_level=1,
|
|
300
|
+
),
|
|
301
|
+
}
|
|
302
|
+
adapter.AddProperties(LE_ADVERTISING_MANAGER_IFACE, advertising_manager_properties)
|
|
303
|
+
adapter.AddMethods(
|
|
304
|
+
LE_ADVERTISING_MANAGER_IFACE,
|
|
305
|
+
[
|
|
306
|
+
("RegisterAdvertisement", "oa{sv}", "", RegisterAdvertisement),
|
|
307
|
+
("UnregisterAdvertisement", "o", "", UnregisterAdvertisement),
|
|
308
|
+
],
|
|
309
|
+
)
|
|
310
|
+
|
|
311
|
+
# Track advertisements per adapter
|
|
312
|
+
adapter.advertisements = []
|
|
313
|
+
|
|
314
|
+
# Advertisement Monitor Manager
|
|
315
|
+
if bluez.enable_monitor_api:
|
|
316
|
+
advertisement_monitor_manager_properties = {
|
|
317
|
+
"SupportedMonitorTypes": dbus.Array(["or_patterns"], variant_level=1),
|
|
318
|
+
}
|
|
319
|
+
adapter.AddProperties(ADVERTISEMENT_MONITOR_MANAGER_IFACE, advertisement_monitor_manager_properties)
|
|
320
|
+
adapter.AddMethods(
|
|
321
|
+
ADVERTISEMENT_MONITOR_MANAGER_IFACE,
|
|
322
|
+
[
|
|
323
|
+
("RegisterMonitor", "o", "", RegisterMonitor),
|
|
324
|
+
("UnregisterMonitor", "o", "", UnregisterMonitor),
|
|
325
|
+
],
|
|
326
|
+
)
|
|
327
|
+
|
|
328
|
+
# Track advertisement monitors per adapter
|
|
329
|
+
adapter.monitors = []
|
|
330
|
+
|
|
256
331
|
manager = mockobject.objects["/"]
|
|
257
332
|
manager.EmitSignal(
|
|
258
333
|
OBJECT_MANAGER_IFACE,
|
|
@@ -652,3 +727,137 @@ def DisconnectDevice(_self, adapter_device_name, device_address):
|
|
|
652
727
|
[],
|
|
653
728
|
],
|
|
654
729
|
)
|
|
730
|
+
|
|
731
|
+
|
|
732
|
+
def RegisterAdvertisement(manager, adv_path, options): # pylint: disable=unused-argument
|
|
733
|
+
if adv_path in manager.advertisements:
|
|
734
|
+
raise dbus.exceptions.DBusException("Already registered: " + adv_path, name="org.bluez.Error.AlreadyExists")
|
|
735
|
+
|
|
736
|
+
if len(manager.advertisements) >= MAX_ADVERTISEMENT_INSTANCES:
|
|
737
|
+
raise dbus.exceptions.DBusException(
|
|
738
|
+
f"Maximum number of advertisements reached: {MAX_ADVERTISEMENT_INSTANCES}",
|
|
739
|
+
name="org.bluez.Error.NotPermitted",
|
|
740
|
+
)
|
|
741
|
+
|
|
742
|
+
manager.advertisements.append(adv_path)
|
|
743
|
+
|
|
744
|
+
manager.UpdateProperties(
|
|
745
|
+
LE_ADVERTISING_MANAGER_IFACE,
|
|
746
|
+
{
|
|
747
|
+
"ActiveInstances": dbus.Byte(len(manager.advertisements)),
|
|
748
|
+
"SupportedInstances": dbus.Byte(MAX_ADVERTISEMENT_INSTANCES - len(manager.advertisements)),
|
|
749
|
+
},
|
|
750
|
+
)
|
|
751
|
+
|
|
752
|
+
|
|
753
|
+
def UnregisterAdvertisement(manager, adv_path):
|
|
754
|
+
try:
|
|
755
|
+
manager.advertisements.remove(adv_path)
|
|
756
|
+
except ValueError:
|
|
757
|
+
raise dbus.exceptions.DBusException(
|
|
758
|
+
"Unknown advertisement: " + adv_path, name="org.bluez.Error.DoesNotExist"
|
|
759
|
+
) from None
|
|
760
|
+
|
|
761
|
+
manager.UpdateProperties(
|
|
762
|
+
LE_ADVERTISING_MANAGER_IFACE,
|
|
763
|
+
{
|
|
764
|
+
"ActiveInstances": dbus.Byte(len(manager.advertisements)),
|
|
765
|
+
"SupportedInstances": dbus.Byte(MAX_ADVERTISEMENT_INSTANCES - len(manager.advertisements)),
|
|
766
|
+
},
|
|
767
|
+
)
|
|
768
|
+
|
|
769
|
+
|
|
770
|
+
@dbus.service.method(BLUEZ_MOCK_IFACE, in_signature="s", out_signature="s")
|
|
771
|
+
def AddAdvertisement(self, adv_name):
|
|
772
|
+
"""Convenience method to add an Advertisement object
|
|
773
|
+
|
|
774
|
+
Creates a simple broadcast advertisement with some manufacturer data.
|
|
775
|
+
|
|
776
|
+
Returns the new object path.
|
|
777
|
+
"""
|
|
778
|
+
path = "/org/dbusmock/bluez/advertisement/" + adv_name
|
|
779
|
+
|
|
780
|
+
adv_properties = {
|
|
781
|
+
"Type": dbus.String("broadcast", variant_level=1),
|
|
782
|
+
"ManufacturerData": dbus.Dictionary(
|
|
783
|
+
# 0xFFFF is the Bluetooth Company Identifier reserved for internal use and testing.
|
|
784
|
+
{dbus.UInt16(0xFFFF): dbus.Array([0x00, 0x01], variant_level=2)},
|
|
785
|
+
signature="qv",
|
|
786
|
+
variant_level=1,
|
|
787
|
+
),
|
|
788
|
+
"Includes": dbus.Array(["local-name"], variant_level=1),
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
self.AddObject(
|
|
792
|
+
path,
|
|
793
|
+
LE_ADVERTISEMENT_IFACE,
|
|
794
|
+
adv_properties,
|
|
795
|
+
[
|
|
796
|
+
("Release", "", "", ""),
|
|
797
|
+
],
|
|
798
|
+
)
|
|
799
|
+
|
|
800
|
+
return path
|
|
801
|
+
|
|
802
|
+
|
|
803
|
+
@dbus.service.method(BLUEZ_MOCK_IFACE, in_signature="s", out_signature="s")
|
|
804
|
+
def AddMonitor(self, monitor_name):
|
|
805
|
+
"""Convenience method to add an Advertisement Monitor
|
|
806
|
+
|
|
807
|
+
Returns the new object path.
|
|
808
|
+
"""
|
|
809
|
+
path = "/org/dbusmock/bluez/monitor/" + monitor_name
|
|
810
|
+
|
|
811
|
+
monitor_properties = {
|
|
812
|
+
"Type": dbus.String("or_patterns", variant_level=1),
|
|
813
|
+
# Example pattern that could be used to scan for an advertisement created by AddAdvertisement()
|
|
814
|
+
"Patterns": dbus.Struct(
|
|
815
|
+
(
|
|
816
|
+
# Start position: 0
|
|
817
|
+
dbus.Byte(0),
|
|
818
|
+
# AD data type: Manufacturer data
|
|
819
|
+
dbus.Byte(0xFF),
|
|
820
|
+
# Vaue of the pattern: 0xFFFF (company identifier), followed by 0x01
|
|
821
|
+
dbus.Array(
|
|
822
|
+
[
|
|
823
|
+
dbus.UInt16(0xFFFF),
|
|
824
|
+
dbus.Byte(0x01),
|
|
825
|
+
]
|
|
826
|
+
),
|
|
827
|
+
),
|
|
828
|
+
signature="yyay",
|
|
829
|
+
variant_level=2,
|
|
830
|
+
),
|
|
831
|
+
}
|
|
832
|
+
|
|
833
|
+
self.AddObject(
|
|
834
|
+
path,
|
|
835
|
+
ADVERTISEMENT_MONITOR_IFACE,
|
|
836
|
+
monitor_properties,
|
|
837
|
+
[
|
|
838
|
+
("Release", "", "", ""),
|
|
839
|
+
("Activate", "", "", ""),
|
|
840
|
+
("DeviceFound", "o", "", ""),
|
|
841
|
+
("DeviceLost", "o", "", ""),
|
|
842
|
+
],
|
|
843
|
+
)
|
|
844
|
+
|
|
845
|
+
return path
|
|
846
|
+
|
|
847
|
+
|
|
848
|
+
def RegisterMonitor(manager, monitor_path):
|
|
849
|
+
if monitor_path in manager.monitors:
|
|
850
|
+
raise dbus.exceptions.DBusException(
|
|
851
|
+
"Already registered: " + monitor_path, name="org.bluez.Error.AlreadyExists"
|
|
852
|
+
)
|
|
853
|
+
|
|
854
|
+
manager.monitors.append(monitor_path)
|
|
855
|
+
|
|
856
|
+
|
|
857
|
+
def UnregisterMonitor(manager, monitor_path):
|
|
858
|
+
try:
|
|
859
|
+
manager.monitors.remove(monitor_path)
|
|
860
|
+
except ValueError:
|
|
861
|
+
raise dbus.exceptions.DBusException(
|
|
862
|
+
"Unknown monitor: " + monitor_path, name="org.bluez.Error.DoesNotExist"
|
|
863
|
+
) from None
|
|
@@ -28,8 +28,12 @@ def load(mock, _parameters):
|
|
|
28
28
|
[
|
|
29
29
|
("GetActive", "", "b", "ret = self.is_active"),
|
|
30
30
|
("GetActiveTime", "", "u", "ret = 1"),
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
(
|
|
32
|
+
"SetActive",
|
|
33
|
+
"b",
|
|
34
|
+
"",
|
|
35
|
+
'self.is_active = args[0]; self.EmitSignal("", "ActiveChanged", "b", [self.is_active])',
|
|
36
|
+
),
|
|
33
37
|
("Lock", "", "", "time.sleep(1); self.SetActive(True)"),
|
|
34
38
|
("ShowMessage", "sss", "", ""),
|
|
35
39
|
("SimulateUserActivity", "", "", ""),
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
"""ModemManager mock template
|
|
2
|
+
|
|
3
|
+
This creates the expected methods and properties of the main
|
|
4
|
+
ModemManager object, but no devices. You can specify any property
|
|
5
|
+
such as DaemonVersion in "parameters".
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
# This program is free software; you can redistribute it and/or modify it under
|
|
9
|
+
# the terms of the GNU Lesser General Public License as published by the Free
|
|
10
|
+
# Software Foundation; either version 3 of the License, or (at your option) any
|
|
11
|
+
# later version. See http://www.gnu.org/copyleft/lgpl.html for the full text
|
|
12
|
+
# of the license.
|
|
13
|
+
|
|
14
|
+
__author__ = "Guido Günther"
|
|
15
|
+
__copyright__ = "2024 The Phosh Developers"
|
|
16
|
+
|
|
17
|
+
import dbus
|
|
18
|
+
|
|
19
|
+
from dbusmock import MOCK_IFACE, OBJECT_MANAGER_IFACE, mockobject
|
|
20
|
+
|
|
21
|
+
BUS_NAME = "org.freedesktop.ModemManager1"
|
|
22
|
+
MAIN_OBJ = "/org/freedesktop/ModemManager1"
|
|
23
|
+
MAIN_IFACE = "org.freedesktop.ModemManager1"
|
|
24
|
+
SYSTEM_BUS = True
|
|
25
|
+
IS_OBJECT_MANAGER = True
|
|
26
|
+
MODEM_IFACE = "org.freedesktop.ModemManager1.Modem"
|
|
27
|
+
MODEM_3GPP_IFACE = "org.freedesktop.ModemManager1.Modem.Modem3gpp"
|
|
28
|
+
MODEM_VOICE_IFACE = "org.freedesktop.ModemManager1.Modem.Voice"
|
|
29
|
+
SIM_IFACE = "org.freedesktop.ModemManager1.Sim"
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class MMModemMode:
|
|
33
|
+
"""
|
|
34
|
+
See
|
|
35
|
+
https://www.freedesktop.org/software/ModemManager/doc/latest/ModemManager/ModemManager-Flags-and-Enumerations.html#MMModemMode
|
|
36
|
+
"""
|
|
37
|
+
|
|
38
|
+
MODE_NONE = 0
|
|
39
|
+
MODE_CS = 1 << 0
|
|
40
|
+
MODE_2G = 1 << 1
|
|
41
|
+
MODE_3G = 1 << 2
|
|
42
|
+
MODE_4G = 1 << 3
|
|
43
|
+
MODE_5G = 1 << 4
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
class MMModemState:
|
|
47
|
+
"""
|
|
48
|
+
See
|
|
49
|
+
https://www.freedesktop.org/software/ModemManager/doc/latest/ModemManager/ModemManager-Flags-and-Enumerations.html#MMModemState
|
|
50
|
+
"""
|
|
51
|
+
|
|
52
|
+
STATE_FAILED = -1
|
|
53
|
+
STATE_UNKNOWN = 0
|
|
54
|
+
STATE_INITIALIZING = 1
|
|
55
|
+
STATE_LOCKED = 2
|
|
56
|
+
STATE_DISABLED = 3
|
|
57
|
+
STATE_DISABLING = 4
|
|
58
|
+
STATE_ENABLING = 5
|
|
59
|
+
STATE_ENABLED = 6
|
|
60
|
+
STATE_SEARCHING = 7
|
|
61
|
+
STATE_REGISTERED = 8
|
|
62
|
+
STATE_DISCONNECTING = 9
|
|
63
|
+
STATE_CONNECTING = 10
|
|
64
|
+
STATE_CONNECTED = 11
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
class MMModemPowerState:
|
|
68
|
+
"""
|
|
69
|
+
See
|
|
70
|
+
https://www.freedesktop.org/software/ModemManager/doc/latest/ModemManager/ModemManager-Flags-and-Enumerations.html#MMModemPowerState
|
|
71
|
+
"""
|
|
72
|
+
|
|
73
|
+
POWER_STATE_UNKNOWN = 0
|
|
74
|
+
POWER_STATE_OFF = 1
|
|
75
|
+
POWER_STATE_LOW = 2
|
|
76
|
+
POWER_STATE_ON = 3
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
class MMModemAccesssTechnology:
|
|
80
|
+
"""
|
|
81
|
+
See
|
|
82
|
+
https://www.freedesktop.org/software/ModemManager/doc/latest/ModemManager/ModemManager-Flags-and-Enumerations.html#MMModemAccessTechnology
|
|
83
|
+
"""
|
|
84
|
+
|
|
85
|
+
ACCESS_TECHNOLOGY_UNKNOWN = 0
|
|
86
|
+
ACCESS_TECHNOLOGY_POTS = 1 << 0
|
|
87
|
+
ACCESS_TECHNOLOGY_GSM = 1 << 1
|
|
88
|
+
ACCESS_TECHNOLOGY_GSM_COMPACT = 1 << 2
|
|
89
|
+
ACCESS_TECHNOLOGY_GPRS = 1 << 3
|
|
90
|
+
ACCESS_TECHNOLOGY_EDGE = 1 << 4
|
|
91
|
+
ACCESS_TECHNOLOGY_UMTS = 1 << 5
|
|
92
|
+
ACCESS_TECHNOLOGY_HSDPA = 1 << 6
|
|
93
|
+
ACCESS_TECHNOLOGY_HSUPA = 1 << 7
|
|
94
|
+
ACCESS_TECHNOLOGY_HSPA = 1 << 8
|
|
95
|
+
ACCESS_TECHNOLOGY_HSPA_PLUS = 1 << 9
|
|
96
|
+
ACCESS_TECHNOLOGY_1XRTT = 1 << 10
|
|
97
|
+
ACCESS_TECHNOLOGY_EVDO0 = 1 << 11
|
|
98
|
+
ACCESS_TECHNOLOGY_EVDOA = 1 << 12
|
|
99
|
+
ACCESS_TECHNOLOGY_EVDOB = 1 << 13
|
|
100
|
+
ACCESS_TECHNOLOGY_LTE = 1 << 14
|
|
101
|
+
ACCESS_TECHNOLOGY_5GNR = 1 << 15
|
|
102
|
+
ACCESS_TECHNOLOGY_LTE_CAT_M = 1 << 16
|
|
103
|
+
ACCESS_TECHNOLOGY_LTE_NB_IOT = 1 << 17
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
def load(mock, parameters):
|
|
107
|
+
methods = [
|
|
108
|
+
("ScanDevices", "", "", ""),
|
|
109
|
+
]
|
|
110
|
+
|
|
111
|
+
props = dbus.Dictionary(
|
|
112
|
+
{
|
|
113
|
+
"Version": parameters.get("DaemonVersion", "1.22"),
|
|
114
|
+
},
|
|
115
|
+
signature="sv",
|
|
116
|
+
)
|
|
117
|
+
|
|
118
|
+
mock.AddMethods(MAIN_IFACE, methods)
|
|
119
|
+
mock.AddProperties(MAIN_IFACE, props)
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
@dbus.service.method(MOCK_IFACE, in_signature="", out_signature="ss")
|
|
123
|
+
def AddSimpleModem(self):
|
|
124
|
+
"""Convenience method to add a simple Modem object
|
|
125
|
+
|
|
126
|
+
Please note that this does not set any global properties.
|
|
127
|
+
|
|
128
|
+
Returns the new object path.
|
|
129
|
+
"""
|
|
130
|
+
modem_path = "/org/freedesktop/ModemManager1/Modems/8"
|
|
131
|
+
sim_path = "/org/freedesktop/ModemManager1/SIM/2"
|
|
132
|
+
manager = mockobject.objects[MAIN_OBJ]
|
|
133
|
+
|
|
134
|
+
modem_props = {
|
|
135
|
+
"State": dbus.Int32(MMModemState.STATE_ENABLED),
|
|
136
|
+
"Model": dbus.String("E1750"),
|
|
137
|
+
"Revision": dbus.String("11.126.08.01.00"),
|
|
138
|
+
"AccessTechnologies": dbus.UInt32(MMModemAccesssTechnology.ACCESS_TECHNOLOGY_LTE),
|
|
139
|
+
"PowerState": dbus.UInt32(MMModemPowerState.POWER_STATE_ON),
|
|
140
|
+
"UnlockRequired": dbus.UInt32(0),
|
|
141
|
+
"UnlockRetries": dbus.Dictionary([], signature="uu"),
|
|
142
|
+
"CurrentModes": dbus.Struct(
|
|
143
|
+
(dbus.UInt32(MMModemMode.MODE_4G), dbus.UInt32(MMModemMode.MODE_4G)), signature="(uu)"
|
|
144
|
+
),
|
|
145
|
+
"SignalQuality": dbus.Struct(
|
|
146
|
+
(dbus.UInt32(70), dbus.Boolean(True)),
|
|
147
|
+
),
|
|
148
|
+
"Sim": dbus.ObjectPath(sim_path),
|
|
149
|
+
"SupportedModes": [
|
|
150
|
+
(dbus.UInt32(MMModemMode.MODE_4G), dbus.UInt32(MMModemMode.MODE_4G)),
|
|
151
|
+
(dbus.UInt32(MMModemMode.MODE_3G | MMModemMode.MODE_2G), dbus.UInt32(MMModemMode.MODE_3G)),
|
|
152
|
+
],
|
|
153
|
+
"SupportedBands": [dbus.UInt32(0)],
|
|
154
|
+
}
|
|
155
|
+
self.AddObject(modem_path, MODEM_IFACE, modem_props, [])
|
|
156
|
+
|
|
157
|
+
modem_3gpp_props = {
|
|
158
|
+
"Imei": dbus.String("doesnotmatter", variant_level=1),
|
|
159
|
+
"OperatorName": dbus.String("TheOperator"),
|
|
160
|
+
"Pco": dbus.Array([], signature="(ubay)"),
|
|
161
|
+
}
|
|
162
|
+
modem = mockobject.objects[modem_path]
|
|
163
|
+
modem.AddProperties(MODEM_3GPP_IFACE, modem_3gpp_props)
|
|
164
|
+
|
|
165
|
+
modem_voice_props = {
|
|
166
|
+
"Calls": dbus.Array([], signature="o"),
|
|
167
|
+
"EmergencyOnly": False,
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
modem.call_waiting = False
|
|
171
|
+
modem_voice_methods = [
|
|
172
|
+
("CallWaitingQuery", "", "b", "ret = self.call_waiting"),
|
|
173
|
+
("CallWaitingSetup", "b", "", "self.call_waiting = args[0]"),
|
|
174
|
+
]
|
|
175
|
+
modem = mockobject.objects[modem_path]
|
|
176
|
+
modem.AddProperties(MODEM_VOICE_IFACE, modem_voice_props)
|
|
177
|
+
modem.AddMethods(MODEM_VOICE_IFACE, modem_voice_methods)
|
|
178
|
+
|
|
179
|
+
manager.EmitSignal(
|
|
180
|
+
OBJECT_MANAGER_IFACE,
|
|
181
|
+
"InterfacesAdded",
|
|
182
|
+
"oa{sa{sv}}",
|
|
183
|
+
[
|
|
184
|
+
dbus.ObjectPath(modem_path),
|
|
185
|
+
{
|
|
186
|
+
MODEM_IFACE: modem_props,
|
|
187
|
+
MODEM_3GPP_IFACE: modem_3gpp_props,
|
|
188
|
+
MODEM_VOICE_IFACE: modem_voice_props,
|
|
189
|
+
},
|
|
190
|
+
],
|
|
191
|
+
)
|
|
192
|
+
|
|
193
|
+
sim_props = {
|
|
194
|
+
"Active": dbus.Boolean(True),
|
|
195
|
+
"Imsi": dbus.String("doesnotmatter"),
|
|
196
|
+
"PreferredNetworks": dbus.Array([], signature="(su)"),
|
|
197
|
+
}
|
|
198
|
+
self.AddObject(sim_path, SIM_IFACE, sim_props, [])
|
|
199
|
+
manager.EmitSignal(
|
|
200
|
+
OBJECT_MANAGER_IFACE,
|
|
201
|
+
"InterfacesAdded",
|
|
202
|
+
"oa{sa{sv}}",
|
|
203
|
+
[
|
|
204
|
+
dbus.ObjectPath(sim_path),
|
|
205
|
+
{SIM_IFACE: sim_props},
|
|
206
|
+
],
|
|
207
|
+
)
|
|
208
|
+
|
|
209
|
+
return (modem_path, sim_path)
|
|
@@ -42,7 +42,7 @@ IS_OBJECT_MANAGER = True
|
|
|
42
42
|
|
|
43
43
|
|
|
44
44
|
# these really want to be dataclasses, but need to drop support for Python 3.6 for that
|
|
45
|
-
class NMState:
|
|
45
|
+
class NMState:
|
|
46
46
|
"""Global state
|
|
47
47
|
|
|
48
48
|
As per https://developer.gnome.org/NetworkManager/unstable/nm-dbus-types.html#NMState
|
|
@@ -58,7 +58,7 @@ class NMState: # pylint: disable=too-few-public-methods
|
|
|
58
58
|
NM_STATE_CONNECTED_GLOBAL = 70
|
|
59
59
|
|
|
60
60
|
|
|
61
|
-
class NMConnectivityState:
|
|
61
|
+
class NMConnectivityState:
|
|
62
62
|
"""Connectvity state
|
|
63
63
|
|
|
64
64
|
As per https://developer.gnome.org/NetworkManager/unstable/nm-dbus-types.html#NMConnectivityState
|
|
@@ -71,7 +71,7 @@ class NMConnectivityState: # pylint: disable=too-few-public-methods
|
|
|
71
71
|
NM_CONNECTIVITY_FULL = 4
|
|
72
72
|
|
|
73
73
|
|
|
74
|
-
class NMActiveConnectionState:
|
|
74
|
+
class NMActiveConnectionState:
|
|
75
75
|
"""Active connection state
|
|
76
76
|
|
|
77
77
|
As per https://developer.gnome.org/NetworkManager/unstable/nm-dbus-types.html#NMActiveConnectionState
|
|
@@ -84,7 +84,7 @@ class NMActiveConnectionState: # pylint: disable=too-few-public-methods
|
|
|
84
84
|
NM_ACTIVE_CONNECTION_STATE_DEACTIVATED = 4
|
|
85
85
|
|
|
86
86
|
|
|
87
|
-
class InfrastructureMode:
|
|
87
|
+
class InfrastructureMode:
|
|
88
88
|
"""Infrastructure mode
|
|
89
89
|
|
|
90
90
|
As per https://developer.gnome.org/NetworkManager/unstable/nm-dbus-types.html#NM80211Mode
|
|
@@ -103,7 +103,7 @@ class InfrastructureMode: # pylint: disable=too-few-public-methods
|
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
|
|
106
|
-
class DeviceState:
|
|
106
|
+
class DeviceState:
|
|
107
107
|
"""Device states
|
|
108
108
|
|
|
109
109
|
As per https://developer.gnome.org/NetworkManager/unstable/nm-dbus-types.html#NMDeviceState
|
|
@@ -124,7 +124,7 @@ class DeviceState: # pylint: disable=too-few-public-methods
|
|
|
124
124
|
FAILED = 120
|
|
125
125
|
|
|
126
126
|
|
|
127
|
-
class NM80211ApSecurityFlags:
|
|
127
|
+
class NM80211ApSecurityFlags:
|
|
128
128
|
"""Security flags
|
|
129
129
|
|
|
130
130
|
As per https://developer.gnome.org/NetworkManager/unstable/nm-dbus-types.html#NM80211ApSecurityFlags
|
|
@@ -147,7 +147,7 @@ class NM80211ApSecurityFlags: # pylint: disable=too-few-public-methods
|
|
|
147
147
|
}
|
|
148
148
|
|
|
149
149
|
|
|
150
|
-
class NM80211ApFlags:
|
|
150
|
+
class NM80211ApFlags:
|
|
151
151
|
"""Device flags
|
|
152
152
|
|
|
153
153
|
As per https://developer.gnome.org/NetworkManager/unstable/nm-dbus-types.html#NM80211ApFlags
|
|
@@ -23,15 +23,17 @@ jobs:
|
|
|
23
23
|
trigger: pull_request
|
|
24
24
|
targets:
|
|
25
25
|
- fedora-all
|
|
26
|
-
- centos-stream-8-x86_64
|
|
27
26
|
- centos-stream-9-x86_64
|
|
27
|
+
# FIXME: broken
|
|
28
|
+
# - centos-stream-10-x86_64
|
|
28
29
|
|
|
29
30
|
- job: tests
|
|
30
31
|
trigger: pull_request
|
|
31
32
|
targets:
|
|
32
33
|
- fedora-all
|
|
33
|
-
- centos-stream-8-x86_64
|
|
34
34
|
- centos-stream-9-x86_64
|
|
35
|
+
# FIXME: broken rpm build above
|
|
36
|
+
# - centos-stream-10-x86_64
|
|
35
37
|
|
|
36
38
|
- job: propose_downstream
|
|
37
39
|
trigger: release
|
|
@@ -26,6 +26,7 @@ dbusmock/templates/gnome_screensaver.py
|
|
|
26
26
|
dbusmock/templates/iio-sensors-proxy.py
|
|
27
27
|
dbusmock/templates/logind.py
|
|
28
28
|
dbusmock/templates/low_memory_monitor.py
|
|
29
|
+
dbusmock/templates/modemmanager.py
|
|
29
30
|
dbusmock/templates/networkmanager.py
|
|
30
31
|
dbusmock/templates/notification_daemon.py
|
|
31
32
|
dbusmock/templates/ofono.py
|
|
@@ -62,6 +63,7 @@ tests/test_gnome_screensaver.py
|
|
|
62
63
|
tests/test_iio_sensors_proxy.py
|
|
63
64
|
tests/test_logind.py
|
|
64
65
|
tests/test_low_memory_monitor.py
|
|
66
|
+
tests/test_modemmanager.py
|
|
65
67
|
tests/test_networkmanager.py
|
|
66
68
|
tests/test_notification_daemon.py
|
|
67
69
|
tests/test_ofono.py
|