python-dbusmock 0.38.1__tar.gz → 0.38.2__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.38.1/python_dbusmock.egg-info → python_dbusmock-0.38.2}/PKG-INFO +1 -1
- {python_dbusmock-0.38.1 → python_dbusmock-0.38.2}/dbusmock/__init__.py +1 -1
- python_dbusmock-0.38.2/dbusmock/_version.py +1 -0
- {python_dbusmock-0.38.1 → python_dbusmock-0.38.2}/dbusmock/mockobject.py +28 -42
- {python_dbusmock-0.38.1 → python_dbusmock-0.38.2}/dbusmock/templates/bluez5.py +2 -2
- {python_dbusmock-0.38.1 → python_dbusmock-0.38.2}/dbusmock/templates/upower.py +1 -1
- {python_dbusmock-0.38.1 → python_dbusmock-0.38.2}/dbusmock/testcase.py +4 -6
- {python_dbusmock-0.38.1 → python_dbusmock-0.38.2}/doc/conf.py +1 -1
- {python_dbusmock-0.38.1 → python_dbusmock-0.38.2}/pyproject.toml +3 -3
- {python_dbusmock-0.38.1 → python_dbusmock-0.38.2/python_dbusmock.egg-info}/PKG-INFO +1 -1
- {python_dbusmock-0.38.1 → python_dbusmock-0.38.2}/python_dbusmock.egg-info/SOURCES.txt +2 -0
- python_dbusmock-0.38.2/python_dbusmock.egg-info/scm_file_list.json +71 -0
- python_dbusmock-0.38.2/python_dbusmock.egg-info/scm_version.json +8 -0
- {python_dbusmock-0.38.1 → python_dbusmock-0.38.2}/tests/run-centos +3 -3
- {python_dbusmock-0.38.1 → python_dbusmock-0.38.2}/tests/run-debian +1 -2
- {python_dbusmock-0.38.1 → python_dbusmock-0.38.2}/tests/run-fedora +3 -3
- {python_dbusmock-0.38.1 → python_dbusmock-0.38.2}/tests/run-ubuntu +1 -2
- {python_dbusmock-0.38.1 → python_dbusmock-0.38.2}/tests/test_api.py +112 -50
- {python_dbusmock-0.38.1 → python_dbusmock-0.38.2}/tests/test_bluez5.py +15 -3
- {python_dbusmock-0.38.1 → python_dbusmock-0.38.2}/tests/test_cli.py +6 -10
- {python_dbusmock-0.38.1 → python_dbusmock-0.38.2}/tests/test_gnome_screensaver.py +1 -1
- {python_dbusmock-0.38.1 → python_dbusmock-0.38.2}/tests/test_gsd_rfkill.py +1 -1
- {python_dbusmock-0.38.1 → python_dbusmock-0.38.2}/tests/test_logind.py +2 -2
- {python_dbusmock-0.38.1 → python_dbusmock-0.38.2}/tests/test_low_memory_monitor.py +1 -1
- {python_dbusmock-0.38.1 → python_dbusmock-0.38.2}/tests/test_modemmanager.py +1 -1
- {python_dbusmock-0.38.1 → python_dbusmock-0.38.2}/tests/test_networkmanager.py +1 -1
- {python_dbusmock-0.38.1 → python_dbusmock-0.38.2}/tests/test_notification_daemon.py +1 -1
- {python_dbusmock-0.38.1 → python_dbusmock-0.38.2}/tests/test_ofono.py +1 -1
- {python_dbusmock-0.38.1 → python_dbusmock-0.38.2}/tests/test_polkitd.py +1 -1
- {python_dbusmock-0.38.1 → python_dbusmock-0.38.2}/tests/test_power_profiles_daemon.py +1 -1
- {python_dbusmock-0.38.1 → python_dbusmock-0.38.2}/tests/test_systemd.py +1 -1
- {python_dbusmock-0.38.1 → python_dbusmock-0.38.2}/tests/test_timedated.py +1 -1
- {python_dbusmock-0.38.1 → python_dbusmock-0.38.2}/tests/test_upower.py +1 -1
- {python_dbusmock-0.38.1 → python_dbusmock-0.38.2}/tests/test_urfkill.py +5 -5
- python_dbusmock-0.38.1/dbusmock/_version.py +0 -1
- {python_dbusmock-0.38.1 → python_dbusmock-0.38.2}/.fmf/version +0 -0
- {python_dbusmock-0.38.1 → python_dbusmock-0.38.2}/.github/workflows/pages.yml +0 -0
- {python_dbusmock-0.38.1 → python_dbusmock-0.38.2}/.github/workflows/release.yml +0 -0
- {python_dbusmock-0.38.1 → python_dbusmock-0.38.2}/.github/workflows/tests.yml +0 -0
- {python_dbusmock-0.38.1 → python_dbusmock-0.38.2}/.gitignore +0 -0
- {python_dbusmock-0.38.1 → python_dbusmock-0.38.2}/.pre-commit-config.yaml +0 -0
- {python_dbusmock-0.38.1 → python_dbusmock-0.38.2}/COPYING +0 -0
- {python_dbusmock-0.38.1 → python_dbusmock-0.38.2}/NEWS +0 -0
- {python_dbusmock-0.38.1 → python_dbusmock-0.38.2}/README.md +0 -0
- {python_dbusmock-0.38.1 → python_dbusmock-0.38.2}/dbusmock/__main__.py +0 -0
- {python_dbusmock-0.38.1 → python_dbusmock-0.38.2}/dbusmock/pytest_fixtures.py +0 -0
- {python_dbusmock-0.38.1 → python_dbusmock-0.38.2}/dbusmock/templates/SKELETON +0 -0
- {python_dbusmock-0.38.1 → python_dbusmock-0.38.2}/dbusmock/templates/__init__.py +0 -0
- {python_dbusmock-0.38.1 → python_dbusmock-0.38.2}/dbusmock/templates/bluez5-obex.py +0 -0
- {python_dbusmock-0.38.1 → python_dbusmock-0.38.2}/dbusmock/templates/gnome_screensaver.py +0 -0
- {python_dbusmock-0.38.1 → python_dbusmock-0.38.2}/dbusmock/templates/gsd_rfkill.py +0 -0
- {python_dbusmock-0.38.1 → python_dbusmock-0.38.2}/dbusmock/templates/logind.py +0 -0
- {python_dbusmock-0.38.1 → python_dbusmock-0.38.2}/dbusmock/templates/low_memory_monitor.py +0 -0
- {python_dbusmock-0.38.1 → python_dbusmock-0.38.2}/dbusmock/templates/modemmanager.py +0 -0
- {python_dbusmock-0.38.1 → python_dbusmock-0.38.2}/dbusmock/templates/networkmanager.py +0 -0
- {python_dbusmock-0.38.1 → python_dbusmock-0.38.2}/dbusmock/templates/notification_daemon.py +0 -0
- {python_dbusmock-0.38.1 → python_dbusmock-0.38.2}/dbusmock/templates/ofono.py +0 -0
- {python_dbusmock-0.38.1 → python_dbusmock-0.38.2}/dbusmock/templates/polkitd.py +0 -0
- {python_dbusmock-0.38.1 → python_dbusmock-0.38.2}/dbusmock/templates/power_profiles_daemon.py +0 -0
- {python_dbusmock-0.38.1 → python_dbusmock-0.38.2}/dbusmock/templates/systemd.py +0 -0
- {python_dbusmock-0.38.1 → python_dbusmock-0.38.2}/dbusmock/templates/timedated.py +0 -0
- {python_dbusmock-0.38.1 → python_dbusmock-0.38.2}/dbusmock/templates/upower_power_profiles_daemon.py +0 -0
- {python_dbusmock-0.38.1 → python_dbusmock-0.38.2}/dbusmock/templates/urfkill.py +0 -0
- {python_dbusmock-0.38.1 → python_dbusmock-0.38.2}/distro/python-dbusmock.spec +0 -0
- {python_dbusmock-0.38.1 → python_dbusmock-0.38.2}/doc/index.rst +0 -0
- {python_dbusmock-0.38.1 → python_dbusmock-0.38.2}/packit.yaml +0 -0
- {python_dbusmock-0.38.1 → python_dbusmock-0.38.2}/plans/all.fmf +0 -0
- {python_dbusmock-0.38.1 → python_dbusmock-0.38.2}/python_dbusmock.egg-info/dependency_links.txt +0 -0
- {python_dbusmock-0.38.1 → python_dbusmock-0.38.2}/python_dbusmock.egg-info/requires.txt +0 -0
- {python_dbusmock-0.38.1 → python_dbusmock-0.38.2}/python_dbusmock.egg-info/top_level.txt +0 -0
- {python_dbusmock-0.38.1 → python_dbusmock-0.38.2}/setup.cfg +0 -0
- {python_dbusmock-0.38.1 → python_dbusmock-0.38.2}/tests/__init__.py +0 -0
- {python_dbusmock-0.38.1 → python_dbusmock-0.38.2}/tests/conftest.py +0 -0
- {python_dbusmock-0.38.1 → python_dbusmock-0.38.2}/tests/main.fmf +0 -0
- {python_dbusmock-0.38.1 → python_dbusmock-0.38.2}/tests/run +0 -0
- {python_dbusmock-0.38.1 → python_dbusmock-0.38.2}/tests/test_api_pytest.py +0 -0
- {python_dbusmock-0.38.1 → python_dbusmock-0.38.2}/tests/test_code.py +0 -0
- {python_dbusmock-0.38.1 → python_dbusmock-0.38.2}/tests/test_readme_examples.py +0 -0
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
from dbusmock.mockobject import MOCK_IFACE, OBJECT_MANAGER_IFACE, DBusMockObject, get_object, get_objects
|
|
6
6
|
from dbusmock.testcase import BusType, DBusTestCase, PrivateDBus, SpawnedMock
|
|
7
7
|
|
|
8
|
-
try: #
|
|
8
|
+
try: # ruff: ignore[non-empty-init-module]
|
|
9
9
|
# created by setuptools_scm
|
|
10
10
|
from dbusmock._version import __version__
|
|
11
11
|
except ImportError:
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.38.2"
|
|
@@ -8,7 +8,6 @@ __copyright__ = """
|
|
|
8
8
|
(c) 2017 - 2022 Martin Pitt <martin@piware.de>
|
|
9
9
|
"""
|
|
10
10
|
|
|
11
|
-
import copy
|
|
12
11
|
import functools
|
|
13
12
|
import importlib
|
|
14
13
|
import importlib.util
|
|
@@ -24,7 +23,7 @@ import dbus
|
|
|
24
23
|
import dbus.service
|
|
25
24
|
|
|
26
25
|
# we do not use this ourselves, but mock methods often want to use this
|
|
27
|
-
os # pyflakes pylint: disable=pointless-statement #
|
|
26
|
+
os # pyflakes pylint: disable=pointless-statement # ruff: ignore[useless-expression]
|
|
28
27
|
|
|
29
28
|
# global path -> DBusMockObject mapping
|
|
30
29
|
objects: Dict[str, "DBusMockObject"] = {}
|
|
@@ -107,37 +106,27 @@ def _format_args(args):
|
|
|
107
106
|
return s
|
|
108
107
|
|
|
109
108
|
|
|
110
|
-
def
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
dbus.types.UInt16,
|
|
120
|
-
dbus.types.UnixFd,
|
|
121
|
-
dbus.types.Byte,
|
|
122
|
-
dbus.types.Double,
|
|
123
|
-
dbus.types.Int64,
|
|
124
|
-
dbus.types.String,
|
|
125
|
-
dbus.types.UInt32,
|
|
126
|
-
]
|
|
127
|
-
container_types = [
|
|
128
|
-
dbus.types.Array,
|
|
129
|
-
dbus.types.Struct,
|
|
130
|
-
dbus.types.Dictionary,
|
|
131
|
-
]
|
|
132
|
-
if isinstance(value, dbus.String):
|
|
133
|
-
return dbus.String(str(value), variant_level=1)
|
|
134
|
-
if type(value) in container_types:
|
|
109
|
+
def _unwrap_variant(value: Any) -> Any:
|
|
110
|
+
"""Return value with variant_level 1 reset to 0.
|
|
111
|
+
|
|
112
|
+
Values received from a "v" argument have variant_level 1. That does not
|
|
113
|
+
change marshalling into a "v" argument, but Message.guess_signature()
|
|
114
|
+
returns "v" for them instead of the actual type. Other values (including
|
|
115
|
+
plain Python types and nested variants) are returned as they are.
|
|
116
|
+
"""
|
|
117
|
+
if getattr(value, "variant_level", 0) != 1:
|
|
135
118
|
return value
|
|
136
|
-
if
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
119
|
+
if isinstance(value, dbus.types.UnixFd):
|
|
120
|
+
# UnixFd can only be constructed from an int or fileno() object, and
|
|
121
|
+
# dups it; take() transfers ownership of the original fd to us
|
|
122
|
+
fd = value.take()
|
|
123
|
+
try:
|
|
124
|
+
return dbus.types.UnixFd(fd)
|
|
125
|
+
finally:
|
|
126
|
+
os.close(fd)
|
|
127
|
+
if isinstance(value, (dbus.Array, dbus.Dictionary, dbus.Struct)):
|
|
128
|
+
return type(value)(value, signature=value.signature)
|
|
129
|
+
return type(value)(value)
|
|
141
130
|
|
|
142
131
|
|
|
143
132
|
def _convert_args(signature: str, args: Tuple[Any, ...]) -> List[Any]:
|
|
@@ -230,7 +219,7 @@ class DBusMockObject(dbus.service.Object): # pylint: disable=too-many-instance-
|
|
|
230
219
|
self._template_parameters: Optional[PropsType] = None
|
|
231
220
|
|
|
232
221
|
# pylint: disable=consider-using-with
|
|
233
|
-
self.logfile = open(logfile, "wb") if logfile else None #
|
|
222
|
+
self.logfile = open(logfile, "wb") if logfile else None # ruff: ignore[open-file-with-context-handler]
|
|
234
223
|
self.is_logfile_owner = True
|
|
235
224
|
self.call_log: List[CallLogType] = []
|
|
236
225
|
self.mock_data = mock_data
|
|
@@ -493,7 +482,7 @@ class DBusMockObject(dbus.service.Object): # pylint: disable=too-many-instance-
|
|
|
493
482
|
# because inspect cannot handle those, so pass on interface and method
|
|
494
483
|
# name as first positional arguments
|
|
495
484
|
# pylint: disable=unnecessary-lambda-assignment
|
|
496
|
-
method = lambda self, *args, **kwargs: DBusMockObject.mock_method( #
|
|
485
|
+
method = lambda self, *args, **kwargs: DBusMockObject.mock_method( # ruff: ignore[lambda-assignment]
|
|
497
486
|
self, interface, name, in_sig, *args, **kwargs
|
|
498
487
|
)
|
|
499
488
|
|
|
@@ -525,13 +514,9 @@ class DBusMockObject(dbus.service.Object): # pylint: disable=too-many-instance-
|
|
|
525
514
|
self.AddMethod(interface, *method)
|
|
526
515
|
|
|
527
516
|
def _set_property(self, interface, name, value):
|
|
528
|
-
#
|
|
529
|
-
#
|
|
530
|
-
|
|
531
|
-
if not isinstance(value, (dbus.Dictionary, dbus.Array)):
|
|
532
|
-
value = copy.copy(value)
|
|
533
|
-
|
|
534
|
-
self.props.setdefault(interface, {})[name] = value
|
|
517
|
+
# values received over D-Bus come out of a "v" argument; unwrap them so that
|
|
518
|
+
# introspection guesses the actual type
|
|
519
|
+
self.props.setdefault(interface, {})[name] = _unwrap_variant(value)
|
|
535
520
|
|
|
536
521
|
@dbus.service.method(MOCK_IFACE, in_signature="sa{sv}", out_signature="")
|
|
537
522
|
def UpdateProperties(self, interface: str, properties: PropsType) -> None:
|
|
@@ -551,7 +536,8 @@ class DBusMockObject(dbus.service.Object): # pylint: disable=too-many-instance-
|
|
|
551
536
|
raise dbus.exceptions.DBusException(f"property {name} not found", name=interface + ".NoSuchProperty")
|
|
552
537
|
|
|
553
538
|
self._set_property(interface, name, value)
|
|
554
|
-
|
|
539
|
+
# not value itself: _set_property() may have consumed it (UnixFd)
|
|
540
|
+
changed_props[name] = self.props[interface][name]
|
|
555
541
|
|
|
556
542
|
self.EmitSignal(dbus.PROPERTIES_IFACE, "PropertiesChanged", "sa{sv}as", [interface, changed_props, []])
|
|
557
543
|
|
|
@@ -142,7 +142,7 @@ def StartDiscovery(adapter):
|
|
|
142
142
|
adapter.props[ADAPTER_IFACE]["Discovering"] = True
|
|
143
143
|
# NOTE: discovery filter support is minimal to mock
|
|
144
144
|
# the Discoverable discovery filter
|
|
145
|
-
if adapter.props[ADAPTER_IFACE]
|
|
145
|
+
if adapter.props[ADAPTER_IFACE].get("DiscoveryFilter") is not None:
|
|
146
146
|
adapter.props[ADAPTER_IFACE]["Discoverable"] = True
|
|
147
147
|
adapter.EmitSignal(
|
|
148
148
|
dbus.PROPERTIES_IFACE,
|
|
@@ -164,7 +164,7 @@ def StopDiscovery(adapter):
|
|
|
164
164
|
adapter.props[ADAPTER_IFACE]["Discovering"] = False
|
|
165
165
|
# NOTE: discovery filter support is minimal to mock
|
|
166
166
|
# the Discoverable discovery filter
|
|
167
|
-
if adapter.props[ADAPTER_IFACE]
|
|
167
|
+
if adapter.props[ADAPTER_IFACE].get("DiscoveryFilter") is not None:
|
|
168
168
|
adapter.props[ADAPTER_IFACE]["Discoverable"] = False
|
|
169
169
|
adapter.EmitSignal(
|
|
170
170
|
dbus.PROPERTIES_IFACE,
|
|
@@ -192,7 +192,7 @@ def AddChargingBattery(self, device_name, model_name, percentage, seconds_to_ful
|
|
|
192
192
|
@dbus.service.method(MOCK_IFACE, in_signature="uuddddxxbsu", out_signature="")
|
|
193
193
|
def SetupDisplayDevice(
|
|
194
194
|
self,
|
|
195
|
-
_type,
|
|
195
|
+
_type,
|
|
196
196
|
state,
|
|
197
197
|
percentage,
|
|
198
198
|
energy,
|
|
@@ -113,8 +113,7 @@ class PrivateDBus:
|
|
|
113
113
|
self._servicedir.mkdir(parents=True)
|
|
114
114
|
|
|
115
115
|
self._config = self._servicedir / f"dbusmock_{self.bustype.value}_cfg"
|
|
116
|
-
self._config.write_text(
|
|
117
|
-
f"""<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-Bus Bus Configuration 1.0//EN"
|
|
116
|
+
self._config.write_text(f"""<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-Bus Bus Configuration 1.0//EN"
|
|
118
117
|
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
|
|
119
118
|
<busconfig>
|
|
120
119
|
<type>{self.bustype.value}</type>
|
|
@@ -128,8 +127,7 @@ class PrivateDBus:
|
|
|
128
127
|
<allow own="*"/>
|
|
129
128
|
</policy>
|
|
130
129
|
</busconfig>
|
|
131
|
-
"""
|
|
132
|
-
)
|
|
130
|
+
""")
|
|
133
131
|
|
|
134
132
|
def __enter__(self):
|
|
135
133
|
# Allow for start() to be called manually even before the `with`
|
|
@@ -376,7 +374,7 @@ class DBusTestCase(unittest.TestCase):
|
|
|
376
374
|
This is a legacy method kept for backwards compatibility,
|
|
377
375
|
use SpawnedMock.spawn_with_template() instead.
|
|
378
376
|
"""
|
|
379
|
-
if system_bus is not None: #
|
|
377
|
+
if system_bus is not None: # ruff: ignore[if-else-block-instead-of-if-exp]
|
|
380
378
|
bustype = BusType.SYSTEM if system_bus else BusType.SESSION
|
|
381
379
|
else:
|
|
382
380
|
bustype = None
|
|
@@ -546,7 +544,7 @@ class SpawnedMock:
|
|
|
546
544
|
|
|
547
545
|
is_object_manager = module.IS_OBJECT_MANAGER if hasattr(module, "IS_OBJECT_MANAGER") else False
|
|
548
546
|
|
|
549
|
-
if is_object_manager and not hasattr(module, "MAIN_IFACE"): #
|
|
547
|
+
if is_object_manager and not hasattr(module, "MAIN_IFACE"): # ruff: ignore[if-else-block-instead-of-if-exp]
|
|
550
548
|
interface_name = OBJECT_MANAGER_IFACE
|
|
551
549
|
else:
|
|
552
550
|
interface_name = module.MAIN_IFACE
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
|
|
8
8
|
|
|
9
9
|
project = "python-dbusmock"
|
|
10
|
-
copyright = "2023 - 2025, Martin Pitt" #
|
|
10
|
+
copyright = "2023 - 2025, Martin Pitt" # ruff: ignore[builtin-variable-shadowing]
|
|
11
11
|
author = "Martin Pitt"
|
|
12
12
|
|
|
13
13
|
try:
|
|
@@ -78,15 +78,15 @@ select = [
|
|
|
78
78
|
"RUF", # ruff rules
|
|
79
79
|
"SIM", # flake8-simplify
|
|
80
80
|
"T10", # flake8-debugger
|
|
81
|
-
"
|
|
81
|
+
"TC", # flake8-type-checking
|
|
82
82
|
"UP", # pyupgrade, e.g. f-string checks
|
|
83
83
|
"W", # warnings (mostly whitespace)
|
|
84
84
|
"YTT", # flake8-2020
|
|
85
85
|
]
|
|
86
86
|
|
|
87
87
|
ignore = [
|
|
88
|
-
"
|
|
89
|
-
"
|
|
88
|
+
"mutable-class-default", # Mutable class attributes should be annotated with `typing.ClassVar`
|
|
89
|
+
"suppressible-exception", # Use `contextlib.suppress(KeyError)` instead of `try`-`except`-`pass`
|
|
90
90
|
]
|
|
91
91
|
|
|
92
92
|
[tool.pytest.ini_options]
|
|
@@ -42,6 +42,8 @@ python_dbusmock.egg-info/PKG-INFO
|
|
|
42
42
|
python_dbusmock.egg-info/SOURCES.txt
|
|
43
43
|
python_dbusmock.egg-info/dependency_links.txt
|
|
44
44
|
python_dbusmock.egg-info/requires.txt
|
|
45
|
+
python_dbusmock.egg-info/scm_file_list.json
|
|
46
|
+
python_dbusmock.egg-info/scm_version.json
|
|
45
47
|
python_dbusmock.egg-info/top_level.txt
|
|
46
48
|
tests/__init__.py
|
|
47
49
|
tests/conftest.py
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
{
|
|
2
|
+
"files": [
|
|
3
|
+
".fmf/version",
|
|
4
|
+
".github/workflows/pages.yml",
|
|
5
|
+
".github/workflows/release.yml",
|
|
6
|
+
".github/workflows/tests.yml",
|
|
7
|
+
".gitignore",
|
|
8
|
+
".pre-commit-config.yaml",
|
|
9
|
+
"COPYING",
|
|
10
|
+
"NEWS",
|
|
11
|
+
"README.md",
|
|
12
|
+
"dbusmock/__init__.py",
|
|
13
|
+
"dbusmock/__main__.py",
|
|
14
|
+
"dbusmock/mockobject.py",
|
|
15
|
+
"dbusmock/pytest_fixtures.py",
|
|
16
|
+
"dbusmock/templates/SKELETON",
|
|
17
|
+
"dbusmock/templates/__init__.py",
|
|
18
|
+
"dbusmock/templates/bluez5-obex.py",
|
|
19
|
+
"dbusmock/templates/bluez5.py",
|
|
20
|
+
"dbusmock/templates/gnome_screensaver.py",
|
|
21
|
+
"dbusmock/templates/gsd_rfkill.py",
|
|
22
|
+
"dbusmock/templates/logind.py",
|
|
23
|
+
"dbusmock/templates/low_memory_monitor.py",
|
|
24
|
+
"dbusmock/templates/modemmanager.py",
|
|
25
|
+
"dbusmock/templates/networkmanager.py",
|
|
26
|
+
"dbusmock/templates/notification_daemon.py",
|
|
27
|
+
"dbusmock/templates/ofono.py",
|
|
28
|
+
"dbusmock/templates/polkitd.py",
|
|
29
|
+
"dbusmock/templates/power_profiles_daemon.py",
|
|
30
|
+
"dbusmock/templates/systemd.py",
|
|
31
|
+
"dbusmock/templates/timedated.py",
|
|
32
|
+
"dbusmock/templates/upower.py",
|
|
33
|
+
"dbusmock/templates/upower_power_profiles_daemon.py",
|
|
34
|
+
"dbusmock/templates/urfkill.py",
|
|
35
|
+
"dbusmock/testcase.py",
|
|
36
|
+
"distro/python-dbusmock.spec",
|
|
37
|
+
"doc/conf.py",
|
|
38
|
+
"doc/index.rst",
|
|
39
|
+
"packit.yaml",
|
|
40
|
+
"plans/all.fmf",
|
|
41
|
+
"pyproject.toml",
|
|
42
|
+
"tests/__init__.py",
|
|
43
|
+
"tests/conftest.py",
|
|
44
|
+
"tests/main.fmf",
|
|
45
|
+
"tests/run",
|
|
46
|
+
"tests/run-centos",
|
|
47
|
+
"tests/run-debian",
|
|
48
|
+
"tests/run-fedora",
|
|
49
|
+
"tests/run-ubuntu",
|
|
50
|
+
"tests/test_api.py",
|
|
51
|
+
"tests/test_api_pytest.py",
|
|
52
|
+
"tests/test_bluez5.py",
|
|
53
|
+
"tests/test_cli.py",
|
|
54
|
+
"tests/test_code.py",
|
|
55
|
+
"tests/test_gnome_screensaver.py",
|
|
56
|
+
"tests/test_gsd_rfkill.py",
|
|
57
|
+
"tests/test_logind.py",
|
|
58
|
+
"tests/test_low_memory_monitor.py",
|
|
59
|
+
"tests/test_modemmanager.py",
|
|
60
|
+
"tests/test_networkmanager.py",
|
|
61
|
+
"tests/test_notification_daemon.py",
|
|
62
|
+
"tests/test_ofono.py",
|
|
63
|
+
"tests/test_polkitd.py",
|
|
64
|
+
"tests/test_power_profiles_daemon.py",
|
|
65
|
+
"tests/test_readme_examples.py",
|
|
66
|
+
"tests/test_systemd.py",
|
|
67
|
+
"tests/test_timedated.py",
|
|
68
|
+
"tests/test_upower.py",
|
|
69
|
+
"tests/test_urfkill.py"
|
|
70
|
+
]
|
|
71
|
+
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
#!/bin/sh
|
|
2
2
|
set -eux
|
|
3
3
|
# install build dependencies
|
|
4
|
-
dnf -y
|
|
4
|
+
dnf -y --disablerepo=fedora-cisco-openh264 install \
|
|
5
|
+
python3-setuptools python3 python3-gobject-base \
|
|
5
6
|
python3-dbus dbus-x11 util-linux \
|
|
6
7
|
upower NetworkManager ModemManager bluez libnotify polkit
|
|
7
8
|
|
|
@@ -22,8 +23,7 @@ mkdir -p /run/systemd/system
|
|
|
22
23
|
|
|
23
24
|
# run build and test as user
|
|
24
25
|
useradd build
|
|
25
|
-
|
|
26
|
-
set -ex
|
|
26
|
+
runuser -u build -- sh -ex << EOF || { [ -z "$DEBUG" ] || sleep infinity; exit 1; }
|
|
27
27
|
cd /source
|
|
28
28
|
export SKIP_STATIC_CHECKS="$SKIP_STATIC_CHECKS"
|
|
29
29
|
|
|
@@ -21,8 +21,7 @@ mkdir -p /run/systemd/system
|
|
|
21
21
|
|
|
22
22
|
# run build and test as user
|
|
23
23
|
useradd build
|
|
24
|
-
|
|
25
|
-
set -ex
|
|
24
|
+
runuser -u build -- sh -ex << EOF || { [ -z "$DEBUG" ] || sleep infinity; exit 1; }
|
|
26
25
|
export SKIP_STATIC_CHECKS="$SKIP_STATIC_CHECKS"
|
|
27
26
|
cp -r $(pwd) /tmp/source
|
|
28
27
|
cd /tmp/source
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
#!/bin/sh
|
|
2
2
|
set -eux
|
|
3
3
|
# install build dependencies
|
|
4
|
-
dnf -y
|
|
4
|
+
dnf -y --disablerepo=fedora-cisco-openh264 install \
|
|
5
|
+
python3-setuptools python3 python3-gobject-base \
|
|
5
6
|
python3-dbus dbus-x11 util-linux \
|
|
6
7
|
upower NetworkManager ModemManager bluez libnotify polkit
|
|
7
8
|
|
|
@@ -22,8 +23,7 @@ mkdir -p /run/systemd/system
|
|
|
22
23
|
|
|
23
24
|
# run build and test as user
|
|
24
25
|
useradd build
|
|
25
|
-
|
|
26
|
-
set -ex
|
|
26
|
+
runuser -u build -- sh -ex << EOF || { [ -z "$DEBUG" ] || sleep infinity; exit 1; }
|
|
27
27
|
cd /source
|
|
28
28
|
export SKIP_STATIC_CHECKS="$SKIP_STATIC_CHECKS"
|
|
29
29
|
|
|
@@ -21,8 +21,7 @@ mkdir -p /run/systemd/system
|
|
|
21
21
|
|
|
22
22
|
# run build and test as user
|
|
23
23
|
useradd build
|
|
24
|
-
|
|
25
|
-
set -ex
|
|
24
|
+
runuser -u build -- sh -ex << EOF || { [ -z "$DEBUG" ] || sleep infinity; exit 1; }
|
|
26
25
|
export SKIP_STATIC_CHECKS="$SKIP_STATIC_CHECKS"
|
|
27
26
|
cp -r $(pwd) /tmp/source
|
|
28
27
|
cd /tmp/source
|
|
@@ -17,6 +17,7 @@ import time
|
|
|
17
17
|
import tracemalloc
|
|
18
18
|
import unittest
|
|
19
19
|
from pathlib import Path
|
|
20
|
+
from xml.etree import ElementTree as ET
|
|
20
21
|
|
|
21
22
|
import dbus
|
|
22
23
|
import dbus.mainloop.glib
|
|
@@ -41,7 +42,7 @@ class TestAPI(dbusmock.DBusTestCase):
|
|
|
41
42
|
|
|
42
43
|
def setUp(self):
|
|
43
44
|
# pylint: disable=consider-using-with
|
|
44
|
-
self.mock_log = tempfile.NamedTemporaryFile() #
|
|
45
|
+
self.mock_log = tempfile.NamedTemporaryFile() # ruff: ignore[open-file-with-context-handler]
|
|
45
46
|
self.p_mock = self.spawn_server(
|
|
46
47
|
"org.freedesktop.Test", "/", "org.freedesktop.Test.Main", stdout=self.mock_log
|
|
47
48
|
)
|
|
@@ -340,6 +341,8 @@ assert args[2] == 5
|
|
|
340
341
|
self.dbus_mock.AddProperty("org.freedesktop.Test.Main", "intarray", dbus.Array([1, 2]))
|
|
341
342
|
self.dbus_mock.AddProperty("org.freedesktop.Test.Main", "vardict", dbus.Dictionary({"a": 1}))
|
|
342
343
|
self.dbus_mock.AddProperty("org.freedesktop.Test.Main", "struct", dbus.Struct((1, "a")))
|
|
344
|
+
self.dbus_mock.AddProperty("org.freedesktop.Test.Main", "path", dbus.ObjectPath("/a"))
|
|
345
|
+
self.dbus_mock.AddProperty("org.freedesktop.Test.Main", "sig", dbus.Signature("s"))
|
|
343
346
|
|
|
344
347
|
changes = [
|
|
345
348
|
{
|
|
@@ -355,6 +358,10 @@ assert args[2] == 5
|
|
|
355
358
|
{
|
|
356
359
|
"struct": (2, "b"),
|
|
357
360
|
},
|
|
361
|
+
{
|
|
362
|
+
"path": dbus.ObjectPath("/b"),
|
|
363
|
+
"sig": dbus.Signature("i"),
|
|
364
|
+
},
|
|
358
365
|
{
|
|
359
366
|
"intarray": [3, 7],
|
|
360
367
|
"vardict": {"d": dbus.Array([42, 1])},
|
|
@@ -407,6 +414,69 @@ assert args[2] == 5
|
|
|
407
414
|
)
|
|
408
415
|
self.assertEqual(self.dbus_props.Get("org.freedesktop.Test.Main", "array"), ["second", "third"])
|
|
409
416
|
|
|
417
|
+
def assertPipeFd(self, unix_fd, pipe_write_fd):
|
|
418
|
+
"""Check that a received UnixFd is the read end of the given pipe"""
|
|
419
|
+
|
|
420
|
+
fd = unix_fd.take()
|
|
421
|
+
self.addCleanup(os.close, fd)
|
|
422
|
+
os.write(pipe_write_fd, b"hello")
|
|
423
|
+
self.assertEqual(os.read(fd, 10), b"hello")
|
|
424
|
+
|
|
425
|
+
def update_properties(self, changes):
|
|
426
|
+
"""Call UpdateProperties() on the main interface, and return the changed properties of the signal"""
|
|
427
|
+
|
|
428
|
+
signals = []
|
|
429
|
+
ml = GLib.MainLoop()
|
|
430
|
+
|
|
431
|
+
def catch(_interface, changed, _invalidated):
|
|
432
|
+
signals.append(changed)
|
|
433
|
+
ml.quit()
|
|
434
|
+
|
|
435
|
+
match = self.dbus_con.add_signal_receiver(catch, "PropertiesChanged", dbus.PROPERTIES_IFACE, path="/")
|
|
436
|
+
self.dbus_mock.UpdateProperties("org.freedesktop.Test.Main", changes)
|
|
437
|
+
timeout = GLib.timeout_add(3000, ml.quit)
|
|
438
|
+
ml.run()
|
|
439
|
+
GLib.source_remove(timeout)
|
|
440
|
+
match.remove()
|
|
441
|
+
|
|
442
|
+
self.assertEqual(len(signals), 1)
|
|
443
|
+
return signals[0]
|
|
444
|
+
|
|
445
|
+
def test_properties_unixfd(self):
|
|
446
|
+
"""property with UnixFd value"""
|
|
447
|
+
|
|
448
|
+
pipe_r, pipe_w = os.pipe()
|
|
449
|
+
self.addCleanup(os.close, pipe_w)
|
|
450
|
+
self.dbus_mock.AddProperty("", "fd", dbus.types.UnixFd(pipe_r))
|
|
451
|
+
os.close(pipe_r)
|
|
452
|
+
|
|
453
|
+
self.assertPipeFd(self.dbus_props.Get("org.freedesktop.Test.Main", "fd"), pipe_w)
|
|
454
|
+
# getting it twice works, the mock keeps its own fd
|
|
455
|
+
self.assertPipeFd(self.dbus_props.Get("org.freedesktop.Test.Main", "fd"), pipe_w)
|
|
456
|
+
|
|
457
|
+
pipe2_r, pipe2_w = os.pipe()
|
|
458
|
+
self.addCleanup(os.close, pipe2_w)
|
|
459
|
+
changed = self.update_properties({"fd": dbus.types.UnixFd(pipe2_r)})
|
|
460
|
+
os.close(pipe2_r)
|
|
461
|
+
self.assertEqual(list(changed), ["fd"])
|
|
462
|
+
self.assertPipeFd(changed["fd"], pipe2_w)
|
|
463
|
+
self.assertPipeFd(self.dbus_props.Get("org.freedesktop.Test.Main", "fd"), pipe2_w)
|
|
464
|
+
|
|
465
|
+
def test_properties_nested_variant(self):
|
|
466
|
+
"""property with variant value"""
|
|
467
|
+
|
|
468
|
+
self.dbus_mock.AddProperty("", "nested", dbus.Int32(1, variant_level=2))
|
|
469
|
+
nested = self.dbus_props.Get("org.freedesktop.Test.Main", "nested")
|
|
470
|
+
self.assertEqual(nested, 1)
|
|
471
|
+
self.assertEqual(nested.variant_level, 2)
|
|
472
|
+
|
|
473
|
+
changed = self.update_properties({"nested": dbus.Int32(2, variant_level=2)})
|
|
474
|
+
self.assertEqual(changed, {"nested": 2})
|
|
475
|
+
self.assertEqual(changed["nested"].variant_level, 2)
|
|
476
|
+
nested = self.dbus_props.Get("org.freedesktop.Test.Main", "nested")
|
|
477
|
+
self.assertEqual(nested, 2)
|
|
478
|
+
self.assertEqual(nested.variant_level, 2)
|
|
479
|
+
|
|
410
480
|
def test_introspection_methods(self):
|
|
411
481
|
"""dynamically added methods appear in introspection"""
|
|
412
482
|
|
|
@@ -442,21 +512,27 @@ assert args[2] == 5
|
|
|
442
512
|
|
|
443
513
|
self.dbus_mock.AddProperty("", "Color", "yellow")
|
|
444
514
|
self.dbus_mock.AddProperty("org.freedesktop.Test.Sub", "Count", 5)
|
|
515
|
+
self.dbus_mock.AddProperty("org.freedesktop.Test.Sub", "Names", dbus.Array(["a"], signature="s"))
|
|
516
|
+
self.dbus_mock.AddProperty("org.freedesktop.Test.Sub", "Map", dbus.Dictionary({"a": 1}, signature="si"))
|
|
517
|
+
self.dbus_mock.AddProperty("org.freedesktop.Test.Sub", "Any", dbus.Int32(1, variant_level=2))
|
|
445
518
|
|
|
446
|
-
xml = self.obj_test.Introspect()
|
|
519
|
+
xml = ET.fromstring(self.obj_test.Introspect())
|
|
447
520
|
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
521
|
+
def props(interface):
|
|
522
|
+
return {
|
|
523
|
+
p.get("name"): (p.get("type"), p.get("access"))
|
|
524
|
+
for p in xml.iterfind(f"interface[@name='{interface}']/property")
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
self.assertEqual(props("org.freedesktop.Test.Main"), {"Color": ("s", "readwrite")})
|
|
528
|
+
self.assertEqual(
|
|
529
|
+
props("org.freedesktop.Test.Sub"),
|
|
530
|
+
{
|
|
531
|
+
"Count": ("i", "readwrite"),
|
|
532
|
+
"Names": ("as", "readwrite"),
|
|
533
|
+
"Map": ("a{si}", "readwrite"),
|
|
534
|
+
"Any": ("v", "readwrite"),
|
|
535
|
+
},
|
|
460
536
|
)
|
|
461
537
|
|
|
462
538
|
def test_objects_map(self):
|
|
@@ -697,8 +773,7 @@ class TestTemplates(dbusmock.DBusTestCase):
|
|
|
697
773
|
"""Load a local template *.py file"""
|
|
698
774
|
|
|
699
775
|
with tempfile.NamedTemporaryFile(prefix="answer_", suffix=".py") as my_template:
|
|
700
|
-
my_template.write(
|
|
701
|
-
b"""import dbus
|
|
776
|
+
my_template.write(b"""import dbus
|
|
702
777
|
BUS_NAME = 'universe.Ultimate'
|
|
703
778
|
MAIN_OBJ = '/'
|
|
704
779
|
MAIN_IFACE = 'universe.Ultimate'
|
|
@@ -706,10 +781,9 @@ SYSTEM_BUS = False
|
|
|
706
781
|
|
|
707
782
|
def load(mock, parameters):
|
|
708
783
|
mock.AddMethods(MAIN_IFACE, [('Answer', 's', 'i', 'ret = 42')])
|
|
709
|
-
"""
|
|
710
|
-
)
|
|
784
|
+
""")
|
|
711
785
|
my_template.flush()
|
|
712
|
-
|
|
786
|
+
p_mock, dbus_ultimate = self.spawn_server_template(my_template.name, stdout=subprocess.PIPE)
|
|
713
787
|
self.addCleanup(p_mock.wait)
|
|
714
788
|
self.addCleanup(p_mock.terminate)
|
|
715
789
|
self.addCleanup(p_mock.stdout.close)
|
|
@@ -765,8 +839,7 @@ def load(mock, parameters):
|
|
|
765
839
|
template_dir = Path(xdg_data_dir) / "python-dbusmock" / "templates"
|
|
766
840
|
template_dir.mkdir(parents=True)
|
|
767
841
|
|
|
768
|
-
(template_dir / "answer.py").write_text(
|
|
769
|
-
"""
|
|
842
|
+
(template_dir / "answer.py").write_text("""
|
|
770
843
|
BUS_NAME = 'universe.Ultimate'
|
|
771
844
|
MAIN_OBJ = '/'
|
|
772
845
|
MAIN_IFACE = 'universe.Ultimate'
|
|
@@ -774,10 +847,9 @@ SYSTEM_BUS = False
|
|
|
774
847
|
|
|
775
848
|
def load(mock, parameters):
|
|
776
849
|
mock.AddMethods(MAIN_IFACE, [('Answer', 's', 'i', 'ret = 42')])
|
|
777
|
-
"""
|
|
778
|
-
)
|
|
850
|
+
""")
|
|
779
851
|
|
|
780
|
-
|
|
852
|
+
p_mock, dbus_ultimate = self.spawn_server_template("answer", stdout=subprocess.PIPE)
|
|
781
853
|
self.addCleanup(p_mock.wait)
|
|
782
854
|
self.addCleanup(p_mock.terminate)
|
|
783
855
|
self.addCleanup(p_mock.stdout.close)
|
|
@@ -790,8 +862,7 @@ def load(mock, parameters):
|
|
|
790
862
|
"""Static method in a template"""
|
|
791
863
|
|
|
792
864
|
with tempfile.NamedTemporaryFile(prefix="answer_", suffix=".py") as my_template:
|
|
793
|
-
my_template.write(
|
|
794
|
-
b"""import dbus
|
|
865
|
+
my_template.write(b"""import dbus
|
|
795
866
|
BUS_NAME = 'universe.Ultimate'
|
|
796
867
|
MAIN_OBJ = '/'
|
|
797
868
|
MAIN_IFACE = 'universe.Ultimate'
|
|
@@ -805,10 +876,9 @@ def load(mock, parameters):
|
|
|
805
876
|
out_signature='i')
|
|
806
877
|
def Answer(self, string):
|
|
807
878
|
return 42
|
|
808
|
-
"""
|
|
809
|
-
)
|
|
879
|
+
""")
|
|
810
880
|
my_template.flush()
|
|
811
|
-
|
|
881
|
+
p_mock, dbus_ultimate = self.spawn_server_template(my_template.name, stdout=subprocess.PIPE)
|
|
812
882
|
self.addCleanup(p_mock.wait)
|
|
813
883
|
self.addCleanup(p_mock.terminate)
|
|
814
884
|
self.addCleanup(p_mock.stdout.close)
|
|
@@ -854,18 +924,16 @@ def Answer(self, string):
|
|
|
854
924
|
"""Explicitly set the bus for a template that does not specify SYSTEM_BUS"""
|
|
855
925
|
|
|
856
926
|
with tempfile.NamedTemporaryFile(prefix="answer_", suffix=".py") as my_template:
|
|
857
|
-
my_template.write(
|
|
858
|
-
b"""import dbus
|
|
927
|
+
my_template.write(b"""import dbus
|
|
859
928
|
BUS_NAME = 'universe.Ultimate'
|
|
860
929
|
MAIN_OBJ = '/'
|
|
861
930
|
MAIN_IFACE = 'universe.Ultimate'
|
|
862
931
|
|
|
863
932
|
def load(mock, parameters):
|
|
864
933
|
mock.AddMethods(MAIN_IFACE, [('Answer', '', 'i', 'ret = 42')])
|
|
865
|
-
"""
|
|
866
|
-
)
|
|
934
|
+
""")
|
|
867
935
|
my_template.flush()
|
|
868
|
-
|
|
936
|
+
p_mock, dbus_ultimate = self.spawn_server_template(
|
|
869
937
|
my_template.name, stdout=subprocess.PIPE, system_bus=False
|
|
870
938
|
)
|
|
871
939
|
self.addCleanup(p_mock.wait)
|
|
@@ -879,8 +947,7 @@ def load(mock, parameters):
|
|
|
879
947
|
"""Override the bus for a template"""
|
|
880
948
|
|
|
881
949
|
with tempfile.NamedTemporaryFile(prefix="answer_", suffix=".py") as my_template:
|
|
882
|
-
my_template.write(
|
|
883
|
-
b"""import dbus
|
|
950
|
+
my_template.write(b"""import dbus
|
|
884
951
|
BUS_NAME = 'universe.Ultimate'
|
|
885
952
|
MAIN_OBJ = '/'
|
|
886
953
|
MAIN_IFACE = 'universe.Ultimate'
|
|
@@ -888,10 +955,9 @@ SYSTEM_BUS = True
|
|
|
888
955
|
|
|
889
956
|
def load(mock, parameters):
|
|
890
957
|
mock.AddMethods(MAIN_IFACE, [('Answer', '', 'i', 'ret = 42')])
|
|
891
|
-
"""
|
|
892
|
-
)
|
|
958
|
+
""")
|
|
893
959
|
my_template.flush()
|
|
894
|
-
|
|
960
|
+
p_mock, dbus_ultimate = self.spawn_server_template(
|
|
895
961
|
my_template.name, stdout=subprocess.PIPE, system_bus=False
|
|
896
962
|
)
|
|
897
963
|
self.addCleanup(p_mock.wait)
|
|
@@ -905,8 +971,7 @@ def load(mock, parameters):
|
|
|
905
971
|
"""Template with ObjectManager API"""
|
|
906
972
|
|
|
907
973
|
with tempfile.NamedTemporaryFile(prefix="objmgr_", suffix=".py") as my_template:
|
|
908
|
-
my_template.write(
|
|
909
|
-
b"""import dbus
|
|
974
|
+
my_template.write(b"""import dbus
|
|
910
975
|
BUS_NAME = 'org.test.Things'
|
|
911
976
|
MAIN_OBJ = '/org/test/Things'
|
|
912
977
|
IS_OBJECT_MANAGER = True
|
|
@@ -916,10 +981,9 @@ def load(mock, parameters):
|
|
|
916
981
|
mock.AddObject('/org/test/Things/Thing1', 'org.test.Do', {'name': 'one'}, [])
|
|
917
982
|
mock.AddObject('/org/test/Things/Thing2', 'org.test.Do', {'name': 'two'}, [])
|
|
918
983
|
mock.AddObject('/org/test/Peer', 'org.test.Do', {'name': 'peer'}, [])
|
|
919
|
-
"""
|
|
920
|
-
)
|
|
984
|
+
""")
|
|
921
985
|
my_template.flush()
|
|
922
|
-
|
|
986
|
+
p_mock, dbus_objmgr = self.spawn_server_template(my_template.name, stdout=subprocess.PIPE)
|
|
923
987
|
self.addCleanup(p_mock.wait)
|
|
924
988
|
self.addCleanup(p_mock.terminate)
|
|
925
989
|
self.addCleanup(p_mock.stdout.close)
|
|
@@ -944,8 +1008,7 @@ def load(mock, parameters):
|
|
|
944
1008
|
"""Template with DBusMockObject subclass"""
|
|
945
1009
|
|
|
946
1010
|
with tempfile.NamedTemporaryFile(prefix="objmgr_", suffix=".py") as my_template:
|
|
947
|
-
my_template.write(
|
|
948
|
-
b"""
|
|
1011
|
+
my_template.write(b"""
|
|
949
1012
|
import dbus
|
|
950
1013
|
import dbusmock
|
|
951
1014
|
BUS_NAME = 'org.test.Things'
|
|
@@ -966,10 +1029,9 @@ def load(mock, parameters):
|
|
|
966
1029
|
mock.AddObject('/org/test/Things/Thing1', MAIN_IFACE, {}, [],
|
|
967
1030
|
mock_class=Thing1,
|
|
968
1031
|
mock_data=42)
|
|
969
|
-
"""
|
|
970
|
-
)
|
|
1032
|
+
""")
|
|
971
1033
|
my_template.flush()
|
|
972
|
-
|
|
1034
|
+
p_mock, _ = self.spawn_server_template(my_template.name, stdout=subprocess.PIPE, system_bus=False)
|
|
973
1035
|
self.addCleanup(p_mock.wait)
|
|
974
1036
|
self.addCleanup(p_mock.terminate)
|
|
975
1037
|
self.addCleanup(p_mock.stdout.close)
|
|
@@ -982,7 +1044,7 @@ def load(mock, parameters):
|
|
|
982
1044
|
def test_reset(self):
|
|
983
1045
|
"""Reset() puts the template back to pristine state"""
|
|
984
1046
|
|
|
985
|
-
|
|
1047
|
+
p_mock, obj_logind = self.spawn_server_template("logind", stdout=subprocess.PIPE)
|
|
986
1048
|
self.addCleanup(p_mock.wait)
|
|
987
1049
|
self.addCleanup(p_mock.terminate)
|
|
988
1050
|
self.addCleanup(p_mock.stdout.close)
|
|
@@ -94,7 +94,7 @@ class TestBlueZ5(dbusmock.DBusTestCase):
|
|
|
94
94
|
def setUpClass(cls):
|
|
95
95
|
cls.start_system_bus()
|
|
96
96
|
cls.dbus_con = cls.get_dbus(True)
|
|
97
|
-
|
|
97
|
+
cls.p_mock, cls.obj_bluez = cls.spawn_server_template("bluez5", {}, stdout=subprocess.PIPE)
|
|
98
98
|
cls.addClassCleanup(cls.p_mock.wait)
|
|
99
99
|
cls.addClassCleanup(cls.p_mock.terminate)
|
|
100
100
|
cls.addClassCleanup(cls.p_mock.stdout.close)
|
|
@@ -232,6 +232,18 @@ class TestBlueZ5(dbusmock.DBusTestCase):
|
|
|
232
232
|
},
|
|
233
233
|
)
|
|
234
234
|
|
|
235
|
+
def test_discovery_without_filter(self):
|
|
236
|
+
path = self.dbusmock_bluez.AddAdapter("hci0", "my-computer")
|
|
237
|
+
adapter = dbus.Interface(self.dbus_con.get_object("org.bluez", path), "org.bluez.Adapter1")
|
|
238
|
+
props = dbus.Interface(self.dbus_con.get_object("org.bluez", path), dbus.PROPERTIES_IFACE)
|
|
239
|
+
|
|
240
|
+
adapter.StartDiscovery()
|
|
241
|
+
self.assertEqual(props.Get("org.bluez.Adapter1", "Discovering"), True)
|
|
242
|
+
self.assertEqual(props.Get("org.bluez.Adapter1", "Discoverable"), False)
|
|
243
|
+
|
|
244
|
+
adapter.StopDiscovery()
|
|
245
|
+
self.assertEqual(props.Get("org.bluez.Adapter1", "Discovering"), False)
|
|
246
|
+
|
|
235
247
|
def test_no_devices(self):
|
|
236
248
|
# Add an adapter.
|
|
237
249
|
adapter_name = "hci0"
|
|
@@ -579,14 +591,14 @@ class TestBlueZObex(dbusmock.DBusTestCase):
|
|
|
579
591
|
|
|
580
592
|
def setUp(self):
|
|
581
593
|
# bluetoothd
|
|
582
|
-
|
|
594
|
+
self.p_mock, self.obj_bluez = self.spawn_server_template("bluez5", {}, stdout=subprocess.PIPE)
|
|
583
595
|
self.addCleanup(self.p_mock.wait)
|
|
584
596
|
self.addCleanup(self.p_mock.terminate)
|
|
585
597
|
self.addCleanup(self.p_mock.stdout.close)
|
|
586
598
|
self.dbusmock_bluez = dbus.Interface(self.obj_bluez, "org.bluez.Mock")
|
|
587
599
|
|
|
588
600
|
# obexd
|
|
589
|
-
|
|
601
|
+
self.p_mock_obex, self.obj_obex = self.spawn_server_template("bluez5-obex", {}, stdout=subprocess.PIPE)
|
|
590
602
|
self.addCleanup(self.p_mock_obex.wait)
|
|
591
603
|
self.addCleanup(self.p_mock_obex.terminate)
|
|
592
604
|
self.addCleanup(self.p_mock_obex.stdout.close)
|
|
@@ -158,8 +158,7 @@ class TestCLI(dbusmock.DBusTestCase):
|
|
|
158
158
|
|
|
159
159
|
def test_template_local(self):
|
|
160
160
|
with tempfile.NamedTemporaryFile(prefix="answer_", suffix=".py") as my_template:
|
|
161
|
-
my_template.write(
|
|
162
|
-
b"""import dbus
|
|
161
|
+
my_template.write(b"""import dbus
|
|
163
162
|
BUS_NAME = 'universe.Ultimate'
|
|
164
163
|
MAIN_OBJ = '/'
|
|
165
164
|
MAIN_IFACE = 'universe.Ultimate'
|
|
@@ -167,8 +166,7 @@ SYSTEM_BUS = False
|
|
|
167
166
|
|
|
168
167
|
def load(mock, parameters):
|
|
169
168
|
mock.AddMethods(MAIN_IFACE, [('Answer', '', 'i', 'ret = 42')])
|
|
170
|
-
"""
|
|
171
|
-
)
|
|
169
|
+
""")
|
|
172
170
|
my_template.flush()
|
|
173
171
|
# template specifies session bus
|
|
174
172
|
self.start_mock(["-t", my_template.name], "universe.Ultimate", "/", False)
|
|
@@ -179,8 +177,7 @@ def load(mock, parameters):
|
|
|
179
177
|
|
|
180
178
|
def test_template_override_system(self):
|
|
181
179
|
with tempfile.NamedTemporaryFile(prefix="answer_", suffix=".py") as my_template:
|
|
182
|
-
my_template.write(
|
|
183
|
-
b"""import dbus
|
|
180
|
+
my_template.write(b"""import dbus
|
|
184
181
|
BUS_NAME = 'universe.Ultimate'
|
|
185
182
|
MAIN_OBJ = '/'
|
|
186
183
|
MAIN_IFACE = 'universe.Ultimate'
|
|
@@ -188,8 +185,7 @@ SYSTEM_BUS = False
|
|
|
188
185
|
|
|
189
186
|
def load(mock, parameters):
|
|
190
187
|
mock.AddMethods(MAIN_IFACE, [('Answer', '', 'i', 'ret = 42')])
|
|
191
|
-
"""
|
|
192
|
-
)
|
|
188
|
+
""")
|
|
193
189
|
my_template.flush()
|
|
194
190
|
# template specifies session bus, but CLI overrides to system
|
|
195
191
|
self.start_mock(["--system", "-t", my_template.name], "universe.Ultimate", "/", True)
|
|
@@ -217,7 +213,7 @@ def load(mock, parameters):
|
|
|
217
213
|
stderr=subprocess.PIPE,
|
|
218
214
|
universal_newlines=True,
|
|
219
215
|
) as p:
|
|
220
|
-
|
|
216
|
+
out, err = p.communicate()
|
|
221
217
|
self.assertEqual(out, "")
|
|
222
218
|
self.assertIn("must specify NAME", err)
|
|
223
219
|
self.assertNotEqual(p.returncode, 0)
|
|
@@ -229,7 +225,7 @@ def load(mock, parameters):
|
|
|
229
225
|
stderr=subprocess.PIPE,
|
|
230
226
|
universal_newlines=True,
|
|
231
227
|
) as p:
|
|
232
|
-
|
|
228
|
+
out, err = p.communicate()
|
|
233
229
|
self.assertEqual(err, "")
|
|
234
230
|
self.assertIn("INTERFACE", out)
|
|
235
231
|
self.assertIn("--system", out)
|
|
@@ -24,7 +24,7 @@ class TestGnomeScreensaver(dbusmock.DBusTestCase):
|
|
|
24
24
|
cls.dbus_con = cls.get_dbus(False)
|
|
25
25
|
|
|
26
26
|
def setUp(self):
|
|
27
|
-
|
|
27
|
+
self.p_mock, self.obj_ss = self.spawn_server_template("gnome_screensaver", {}, stdout=subprocess.PIPE)
|
|
28
28
|
self.addCleanup(self.p_mock.wait)
|
|
29
29
|
self.addCleanup(self.p_mock.terminate)
|
|
30
30
|
self.addCleanup(self.p_mock.stdout.close)
|
|
@@ -23,7 +23,7 @@ class TestGsdRfkill(dbusmock.DBusTestCase):
|
|
|
23
23
|
cls.dbus_con = cls.get_dbus()
|
|
24
24
|
|
|
25
25
|
def setUp(self):
|
|
26
|
-
|
|
26
|
+
self.p_mock, self.p_obj = self.spawn_server_template("gsd_rfkill", {}, stdout=subprocess.PIPE)
|
|
27
27
|
self.addCleanup(self.p_mock.wait)
|
|
28
28
|
self.addCleanup(self.p_mock.terminate)
|
|
29
29
|
self.addCleanup(self.p_mock.stdout.close)
|
|
@@ -39,7 +39,7 @@ class TestLogind(dbusmock.DBusTestCase):
|
|
|
39
39
|
cls.version = re.search(r"(\d+)", out.splitlines()[0]).group(1)
|
|
40
40
|
|
|
41
41
|
def setUp(self):
|
|
42
|
-
|
|
42
|
+
self.p_mock, self.obj_logind = self.spawn_server_template("logind", {}, stdout=subprocess.PIPE)
|
|
43
43
|
self.addCleanup(self.p_mock.wait)
|
|
44
44
|
self.addCleanup(self.p_mock.terminate)
|
|
45
45
|
self.addCleanup(self.p_mock.stdout.close)
|
|
@@ -129,7 +129,7 @@ class TestLogind(dbusmock.DBusTestCase):
|
|
|
129
129
|
self.assertRegex(out, "No inhibitors|0 inhibitors listed")
|
|
130
130
|
|
|
131
131
|
def test_suspend(self):
|
|
132
|
-
|
|
132
|
+
p_mock_polkit, _obj_polkitd = self.spawn_server_template("polkitd", {}, stdout=subprocess.DEVNULL)
|
|
133
133
|
self.addCleanup(p_mock_polkit.wait)
|
|
134
134
|
self.addCleanup(p_mock_polkit.terminate)
|
|
135
135
|
|
|
@@ -29,7 +29,7 @@ class TestLowMemoryMonitor(dbusmock.DBusTestCase):
|
|
|
29
29
|
cls.dbus_con = cls.get_dbus(True)
|
|
30
30
|
|
|
31
31
|
def setUp(self):
|
|
32
|
-
|
|
32
|
+
self.p_mock, self.obj_lmm = self.spawn_server_template("low_memory_monitor", {}, stdout=subprocess.PIPE)
|
|
33
33
|
self.addCleanup(self.p_mock.wait)
|
|
34
34
|
self.addCleanup(self.p_mock.terminate)
|
|
35
35
|
self.addCleanup(self.p_mock.stdout.close)
|
|
@@ -37,7 +37,7 @@ class TestModemManagerBase(dbusmock.DBusTestCase):
|
|
|
37
37
|
|
|
38
38
|
def setUp(self):
|
|
39
39
|
super().setUp()
|
|
40
|
-
|
|
40
|
+
self.p_mock, self.p_obj = self.spawn_server_template("modemmanager", {}, stdout=subprocess.PIPE)
|
|
41
41
|
self.addCleanup(self.p_mock.wait)
|
|
42
42
|
self.addCleanup(self.p_mock.terminate)
|
|
43
43
|
self.addCleanup(self.p_mock.stdout.close)
|
|
@@ -63,7 +63,7 @@ class TestNetworkManager(dbusmock.DBusTestCase):
|
|
|
63
63
|
cls.lang_env["LC_MESSAGES"] = "C"
|
|
64
64
|
|
|
65
65
|
def setUp(self):
|
|
66
|
-
|
|
66
|
+
self.p_mock, self.obj_networkmanager = self.spawn_server_template(
|
|
67
67
|
"networkmanager", {"NetworkingEnabled": True, "WwanEnabled": False}, stdout=subprocess.PIPE
|
|
68
68
|
)
|
|
69
69
|
self.addCleanup(self.p_mock.wait)
|
|
@@ -34,7 +34,7 @@ class TestNotificationDaemon(dbusmock.DBusTestCase):
|
|
|
34
34
|
cls.dbus_con = cls.get_dbus(False)
|
|
35
35
|
|
|
36
36
|
def setUp(self):
|
|
37
|
-
|
|
37
|
+
self.p_mock, self.obj_daemon = self.spawn_server_template("notification_daemon", {}, stdout=subprocess.PIPE)
|
|
38
38
|
self.addCleanup(self.p_mock.wait)
|
|
39
39
|
self.addCleanup(self.p_mock.terminate)
|
|
40
40
|
self.addCleanup(self.p_mock.stdout.close)
|
|
@@ -29,7 +29,7 @@ class TestOfono(dbusmock.DBusTestCase):
|
|
|
29
29
|
def setUpClass(cls):
|
|
30
30
|
cls.start_system_bus()
|
|
31
31
|
cls.dbus_con = cls.get_dbus(True)
|
|
32
|
-
|
|
32
|
+
cls.p_mock, cls.obj_ofono = cls.spawn_server_template("ofono", {}, stdout=subprocess.PIPE)
|
|
33
33
|
cls.addClassCleanup(cls.p_mock.wait)
|
|
34
34
|
cls.addClassCleanup(cls.p_mock.terminate)
|
|
35
35
|
cls.addClassCleanup(cls.p_mock.stdout.close)
|
|
@@ -30,7 +30,7 @@ class TestPolkit(dbusmock.DBusTestCase):
|
|
|
30
30
|
cls.dbus_con = cls.get_dbus(True)
|
|
31
31
|
|
|
32
32
|
def setUp(self):
|
|
33
|
-
|
|
33
|
+
self.p_mock, self.obj_polkitd = self.spawn_server_template("polkitd", {}, stdout=subprocess.PIPE)
|
|
34
34
|
self.addCleanup(self.p_mock.wait)
|
|
35
35
|
self.addCleanup(self.p_mock.terminate)
|
|
36
36
|
self.addCleanup(self.p_mock.stdout.close)
|
|
@@ -46,7 +46,7 @@ class TestPowerProfilesDaemon(dbusmock.DBusTestCase):
|
|
|
46
46
|
print("Failed to get powerprofilesctl version, assuming >= 0.20:", e, file=sys.stderr)
|
|
47
47
|
template = "upower_power_profiles_daemon"
|
|
48
48
|
|
|
49
|
-
|
|
49
|
+
self.p_mock, self.obj_ppd = self.spawn_server_template(template, {}, stdout=subprocess.PIPE)
|
|
50
50
|
self.addCleanup(self.p_mock.wait)
|
|
51
51
|
self.addCleanup(self.p_mock.terminate)
|
|
52
52
|
self.addCleanup(self.p_mock.stdout.close)
|
|
@@ -36,7 +36,7 @@ class TestSystemd(dbusmock.DBusTestCase):
|
|
|
36
36
|
def _test_base(self, bus, system_bus=True):
|
|
37
37
|
dummy_service = "dummy-dbusmock.service"
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
p_mock, obj_systemd = self.spawn_server_template("systemd", {}, subprocess.PIPE, system_bus=system_bus)
|
|
40
40
|
self.addCleanup(p_mock.wait)
|
|
41
41
|
self.addCleanup(p_mock.terminate)
|
|
42
42
|
self.addCleanup(p_mock.stdout.close)
|
|
@@ -31,7 +31,7 @@ class TestTimedated(dbusmock.DBusTestCase):
|
|
|
31
31
|
cls.dbus_con = cls.get_dbus(True)
|
|
32
32
|
|
|
33
33
|
def setUp(self):
|
|
34
|
-
|
|
34
|
+
self.p_mock, _ = self.spawn_server_template("timedated", {}, stdout=subprocess.PIPE)
|
|
35
35
|
self.addCleanup(self.p_mock.wait)
|
|
36
36
|
self.addCleanup(self.p_mock.terminate)
|
|
37
37
|
self.addCleanup(self.p_mock.stdout.close)
|
|
@@ -36,7 +36,7 @@ class TestUPower(dbusmock.DBusTestCase):
|
|
|
36
36
|
cls.dbus_con = cls.get_dbus(True)
|
|
37
37
|
|
|
38
38
|
def setUp(self):
|
|
39
|
-
|
|
39
|
+
self.p_mock, self.obj_upower = self.spawn_server_template(
|
|
40
40
|
"upower",
|
|
41
41
|
{
|
|
42
42
|
"OnBattery": True,
|
|
@@ -33,7 +33,7 @@ class TestURfkill(dbusmock.DBusTestCase):
|
|
|
33
33
|
cls.dbus_con = cls.get_dbus(True)
|
|
34
34
|
|
|
35
35
|
def setUp(self):
|
|
36
|
-
|
|
36
|
+
self.p_mock, self.obj_urfkill = self.spawn_server_template("urfkill", {}, stdout=subprocess.PIPE)
|
|
37
37
|
self.addCleanup(self.p_mock.wait)
|
|
38
38
|
self.addCleanup(self.p_mock.terminate)
|
|
39
39
|
self.addCleanup(self.p_mock.stdout.close)
|
|
@@ -43,7 +43,7 @@ class TestURfkill(dbusmock.DBusTestCase):
|
|
|
43
43
|
self.dbusmock = dbus.Interface(self.obj_urfkill, dbusmock.MOCK_IFACE)
|
|
44
44
|
|
|
45
45
|
def test_mainobject(self):
|
|
46
|
-
|
|
46
|
+
remote_object, iface = _get_urfkill_objects()
|
|
47
47
|
self.assertFalse(iface.IsFlightMode())
|
|
48
48
|
propiface = dbus.Interface(remote_object, dbus.PROPERTIES_IFACE)
|
|
49
49
|
version = propiface.Get("org.freedesktop.URfkill", "DaemonVersion")
|
|
@@ -61,7 +61,7 @@ class TestURfkill(dbusmock.DBusTestCase):
|
|
|
61
61
|
|
|
62
62
|
def test_block(self):
|
|
63
63
|
bus = dbus.SystemBus()
|
|
64
|
-
|
|
64
|
+
_, iface = _get_urfkill_objects()
|
|
65
65
|
|
|
66
66
|
property_object = bus.get_object("org.freedesktop.URfkill", "/org/freedesktop/URfkill/WLAN")
|
|
67
67
|
propiface = dbus.Interface(property_object, dbus.PROPERTIES_IFACE)
|
|
@@ -78,7 +78,7 @@ class TestURfkill(dbusmock.DBusTestCase):
|
|
|
78
78
|
|
|
79
79
|
def test_flightmode(self):
|
|
80
80
|
bus = dbus.SystemBus()
|
|
81
|
-
|
|
81
|
+
_, iface = _get_urfkill_objects()
|
|
82
82
|
|
|
83
83
|
property_object = bus.get_object("org.freedesktop.URfkill", "/org/freedesktop/URfkill/WLAN")
|
|
84
84
|
propiface = dbus.Interface(property_object, dbus.PROPERTIES_IFACE)
|
|
@@ -95,7 +95,7 @@ class TestURfkill(dbusmock.DBusTestCase):
|
|
|
95
95
|
def test_flightmode_restore(self):
|
|
96
96
|
# An interface that was blocked remains blocked once flightmode is removed.
|
|
97
97
|
bus = dbus.SystemBus()
|
|
98
|
-
|
|
98
|
+
_, iface = _get_urfkill_objects()
|
|
99
99
|
|
|
100
100
|
property_object = bus.get_object("org.freedesktop.URfkill", "/org/freedesktop/URfkill/WLAN")
|
|
101
101
|
propiface = dbus.Interface(property_object, dbus.PROPERTIES_IFACE)
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.38.1"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{python_dbusmock-0.38.1 → python_dbusmock-0.38.2}/dbusmock/templates/power_profiles_daemon.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{python_dbusmock-0.38.1 → python_dbusmock-0.38.2}/dbusmock/templates/upower_power_profiles_daemon.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{python_dbusmock-0.38.1 → python_dbusmock-0.38.2}/python_dbusmock.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|