python-dbusmock 0.32.2__tar.gz → 0.34.0__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.
Files changed (80) hide show
  1. python_dbusmock-0.34.0/.github/release.eloquent.yml +2 -0
  2. {python-dbusmock-0.32.2 → python_dbusmock-0.34.0}/.github/workflows/release.yml +6 -7
  3. {python-dbusmock-0.32.2 → python_dbusmock-0.34.0}/.github/workflows/tests.yml +1 -1
  4. {python-dbusmock-0.32.2/python_dbusmock.egg-info → python_dbusmock-0.34.0}/PKG-INFO +172 -7
  5. {python-dbusmock-0.32.2 → python_dbusmock-0.34.0}/dbusmock/__init__.py +0 -1
  6. {python-dbusmock-0.32.2 → python_dbusmock-0.34.0}/dbusmock/__main__.py +0 -1
  7. python_dbusmock-0.34.0/dbusmock/_version.py +1 -0
  8. {python-dbusmock-0.32.2 → python_dbusmock-0.34.0}/dbusmock/mockobject.py +32 -3
  9. {python-dbusmock-0.32.2 → python_dbusmock-0.34.0}/dbusmock/templates/bluez5.py +3 -3
  10. python_dbusmock-0.34.0/dbusmock/templates/gsd_rfkill.py +54 -0
  11. {python-dbusmock-0.32.2 → python_dbusmock-0.34.0}/dbusmock/templates/modemmanager.py +84 -10
  12. {python-dbusmock-0.32.2 → python_dbusmock-0.34.0}/dbusmock/templates/upower.py +1 -1
  13. {python-dbusmock-0.32.2 → python_dbusmock-0.34.0}/dbusmock/testcase.py +1 -1
  14. {python-dbusmock-0.32.2 → python_dbusmock-0.34.0}/packit.yaml +6 -7
  15. {python-dbusmock-0.32.2 → python_dbusmock-0.34.0}/pyproject.toml +2 -2
  16. {python-dbusmock-0.32.2 → python_dbusmock-0.34.0/python_dbusmock.egg-info}/PKG-INFO +172 -7
  17. {python-dbusmock-0.32.2 → python_dbusmock-0.34.0}/python_dbusmock.egg-info/SOURCES.txt +2 -0
  18. {python-dbusmock-0.32.2 → python_dbusmock-0.34.0}/tests/run-debian +0 -7
  19. {python-dbusmock-0.32.2 → python_dbusmock-0.34.0}/tests/run-ubuntu +0 -7
  20. {python-dbusmock-0.32.2 → python_dbusmock-0.34.0}/tests/test_api.py +39 -0
  21. {python-dbusmock-0.32.2 → python_dbusmock-0.34.0}/tests/test_api_pytest.py +1 -1
  22. {python-dbusmock-0.32.2 → python_dbusmock-0.34.0}/tests/test_bluez5.py +9 -14
  23. {python-dbusmock-0.32.2 → python_dbusmock-0.34.0}/tests/test_cli.py +6 -6
  24. python_dbusmock-0.34.0/tests/test_gsd_rfkill.py +63 -0
  25. {python-dbusmock-0.32.2 → python_dbusmock-0.34.0}/tests/test_logind.py +12 -12
  26. {python-dbusmock-0.32.2 → python_dbusmock-0.34.0}/tests/test_modemmanager.py +16 -0
  27. {python-dbusmock-0.32.2 → python_dbusmock-0.34.0}/tests/test_networkmanager.py +9 -13
  28. {python-dbusmock-0.32.2 → python_dbusmock-0.34.0}/tests/test_notification_daemon.py +1 -1
  29. {python-dbusmock-0.32.2 → python_dbusmock-0.34.0}/tests/test_ofono.py +1 -1
  30. {python-dbusmock-0.32.2 → python_dbusmock-0.34.0}/tests/test_power_profiles_daemon.py +4 -4
  31. {python-dbusmock-0.32.2 → python_dbusmock-0.34.0}/tests/test_timedated.py +1 -1
  32. {python-dbusmock-0.32.2 → python_dbusmock-0.34.0}/tests/test_upower.py +5 -5
  33. python-dbusmock-0.32.2/.github/release.eloquent.yml +0 -2
  34. python-dbusmock-0.32.2/dbusmock/_version.py +0 -1
  35. {python-dbusmock-0.32.2 → python_dbusmock-0.34.0}/.fmf/version +0 -0
  36. {python-dbusmock-0.32.2 → python_dbusmock-0.34.0}/.github/workflows/pages.yml +0 -0
  37. {python-dbusmock-0.32.2 → python_dbusmock-0.34.0}/.gitignore +0 -0
  38. {python-dbusmock-0.32.2 → python_dbusmock-0.34.0}/.pre-commit-config.yaml +0 -0
  39. {python-dbusmock-0.32.2 → python_dbusmock-0.34.0}/COPYING +0 -0
  40. {python-dbusmock-0.32.2 → python_dbusmock-0.34.0}/NEWS +0 -0
  41. {python-dbusmock-0.32.2 → python_dbusmock-0.34.0}/README.md +0 -0
  42. {python-dbusmock-0.32.2 → python_dbusmock-0.34.0}/dbusmock/pytest_fixtures.py +0 -0
  43. {python-dbusmock-0.32.2 → python_dbusmock-0.34.0}/dbusmock/templates/SKELETON +0 -0
  44. {python-dbusmock-0.32.2 → python_dbusmock-0.34.0}/dbusmock/templates/__init__.py +0 -0
  45. {python-dbusmock-0.32.2 → python_dbusmock-0.34.0}/dbusmock/templates/bluez5-obex.py +0 -0
  46. {python-dbusmock-0.32.2 → python_dbusmock-0.34.0}/dbusmock/templates/gnome_screensaver.py +0 -0
  47. {python-dbusmock-0.32.2 → python_dbusmock-0.34.0}/dbusmock/templates/iio-sensors-proxy.py +0 -0
  48. {python-dbusmock-0.32.2 → python_dbusmock-0.34.0}/dbusmock/templates/logind.py +0 -0
  49. {python-dbusmock-0.32.2 → python_dbusmock-0.34.0}/dbusmock/templates/low_memory_monitor.py +0 -0
  50. {python-dbusmock-0.32.2 → python_dbusmock-0.34.0}/dbusmock/templates/networkmanager.py +0 -0
  51. {python-dbusmock-0.32.2 → python_dbusmock-0.34.0}/dbusmock/templates/notification_daemon.py +0 -0
  52. {python-dbusmock-0.32.2 → python_dbusmock-0.34.0}/dbusmock/templates/ofono.py +0 -0
  53. {python-dbusmock-0.32.2 → python_dbusmock-0.34.0}/dbusmock/templates/polkitd.py +0 -0
  54. {python-dbusmock-0.32.2 → python_dbusmock-0.34.0}/dbusmock/templates/power_profiles_daemon.py +0 -0
  55. {python-dbusmock-0.32.2 → python_dbusmock-0.34.0}/dbusmock/templates/systemd.py +0 -0
  56. {python-dbusmock-0.32.2 → python_dbusmock-0.34.0}/dbusmock/templates/timedated.py +0 -0
  57. {python-dbusmock-0.32.2 → python_dbusmock-0.34.0}/dbusmock/templates/upower_power_profiles_daemon.py +0 -0
  58. {python-dbusmock-0.32.2 → python_dbusmock-0.34.0}/dbusmock/templates/urfkill.py +0 -0
  59. {python-dbusmock-0.32.2 → python_dbusmock-0.34.0}/doc/conf.py +0 -0
  60. {python-dbusmock-0.32.2 → python_dbusmock-0.34.0}/doc/index.rst +0 -0
  61. {python-dbusmock-0.32.2 → python_dbusmock-0.34.0}/packaging/python-dbusmock.spec +0 -0
  62. {python-dbusmock-0.32.2 → python_dbusmock-0.34.0}/plans/all.fmf +0 -0
  63. {python-dbusmock-0.32.2 → python_dbusmock-0.34.0}/python_dbusmock.egg-info/dependency_links.txt +0 -0
  64. {python-dbusmock-0.32.2 → python_dbusmock-0.34.0}/python_dbusmock.egg-info/requires.txt +0 -0
  65. {python-dbusmock-0.32.2 → python_dbusmock-0.34.0}/python_dbusmock.egg-info/top_level.txt +0 -0
  66. {python-dbusmock-0.32.2 → python_dbusmock-0.34.0}/setup.cfg +0 -0
  67. {python-dbusmock-0.32.2 → python_dbusmock-0.34.0}/setup.py +0 -0
  68. {python-dbusmock-0.32.2 → python_dbusmock-0.34.0}/tests/__init__.py +0 -0
  69. {python-dbusmock-0.32.2 → python_dbusmock-0.34.0}/tests/conftest.py +0 -0
  70. {python-dbusmock-0.32.2 → python_dbusmock-0.34.0}/tests/main.fmf +0 -0
  71. {python-dbusmock-0.32.2 → python_dbusmock-0.34.0}/tests/run +0 -0
  72. {python-dbusmock-0.32.2 → python_dbusmock-0.34.0}/tests/run-centos +0 -0
  73. {python-dbusmock-0.32.2 → python_dbusmock-0.34.0}/tests/run-fedora +0 -0
  74. {python-dbusmock-0.32.2 → python_dbusmock-0.34.0}/tests/test_code.py +0 -0
  75. {python-dbusmock-0.32.2 → python_dbusmock-0.34.0}/tests/test_gnome_screensaver.py +0 -0
  76. {python-dbusmock-0.32.2 → python_dbusmock-0.34.0}/tests/test_iio_sensors_proxy.py +0 -0
  77. {python-dbusmock-0.32.2 → python_dbusmock-0.34.0}/tests/test_low_memory_monitor.py +0 -0
  78. {python-dbusmock-0.32.2 → python_dbusmock-0.34.0}/tests/test_polkitd.py +0 -0
  79. {python-dbusmock-0.32.2 → python_dbusmock-0.34.0}/tests/test_systemd.py +0 -0
  80. {python-dbusmock-0.32.2 → python_dbusmock-0.34.0}/tests/test_urfkill.py +0 -0
@@ -0,0 +1,2 @@
1
+ assets:
2
+ - path: dist/python_dbusmock*.tar.*
@@ -6,7 +6,7 @@ on:
6
6
  - '[0-9]*'
7
7
  jobs:
8
8
  release:
9
- runs-on: ubuntu-22.04
9
+ runs-on: ubuntu-24.04
10
10
  environment: release
11
11
  permissions:
12
12
  # PyPI trusted publisher
@@ -26,19 +26,18 @@ jobs:
26
26
  - name: Install dependencies
27
27
  run: |
28
28
  sudo apt-get update
29
- sudo apt-get install -y python3-setuptools python3-setuptools-scm python3-dbus
30
- dpkg -l
29
+ sudo apt-get install -y python3-build python3-setuptools python3-setuptools-scm python3-venv
31
30
 
32
31
  - name: Build release tarball
33
- run: ./setup.py sdist
32
+ run: python3 -m build --sdist
34
33
 
35
34
  - name: Sanity check
36
35
  run: |
37
36
  set -eux
38
37
  mkdir tmp
39
38
  cd tmp
40
- tar xf ../dist/python-dbusmock-${{ github.ref_name }}.tar.gz
41
- cd python-dbusmock-*
39
+ tar xf ../dist/python_dbusmock-${{ github.ref_name }}.tar.gz
40
+ cd python_dbusmock-*
42
41
  test "$(PYTHONPATH=. python3 -c 'import dbusmock; print(dbusmock.__version__)')" = "${{ github.ref_name }}"
43
42
  PYTHONPATH=. python3 tests/test_api.py
44
43
  cd ../..
@@ -47,7 +46,7 @@ jobs:
47
46
  - name: Create GitHub release
48
47
  uses: cockpit-project/action-release@7d2e2657382e8d34f88a24b5987f2b81ea165785
49
48
  with:
50
- filename: "dist/python-dbusmock-${{ github.ref_name }}.tar.gz"
49
+ filename: "dist/python_dbusmock-${{ github.ref_name }}.tar.gz"
51
50
 
52
51
  - name: Create PyPy release
53
52
  uses: pypa/gh-action-pypi-publish@release/v1
@@ -6,7 +6,7 @@ on:
6
6
  - cron: 0 4 * * MON,FRI
7
7
  jobs:
8
8
  OS:
9
- runs-on: ubuntu-latest
9
+ runs-on: ubuntu-24.04
10
10
  strategy:
11
11
  fail-fast: false
12
12
  matrix:
@@ -1,13 +1,178 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: python-dbusmock
3
- Version: 0.32.2
3
+ Version: 0.34.0
4
4
  Summary: Mock D-Bus objects
5
5
  Home-page: https://github.com/martinpitt/python-dbusmock
6
- Author: Martin Pitt
7
- Author-email: martin@piware.de
8
- License: LGPL 3+
9
6
  Download-URL: https://pypi.python.org/pypi/python-dbusmock/
10
- Platform: UNKNOWN
7
+ Author: Martin Pitt
8
+ Author-email: Martin Pitt <martin@piware.de>
9
+ License: GNU LESSER GENERAL PUBLIC LICENSE
10
+ Version 3, 29 June 2007
11
+
12
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
13
+ Everyone is permitted to copy and distribute verbatim copies
14
+ of this license document, but changing it is not allowed.
15
+
16
+
17
+ This version of the GNU Lesser General Public License incorporates
18
+ the terms and conditions of version 3 of the GNU General Public
19
+ License, supplemented by the additional permissions listed below.
20
+
21
+ 0. Additional Definitions.
22
+
23
+ As used herein, "this License" refers to version 3 of the GNU Lesser
24
+ General Public License, and the "GNU GPL" refers to version 3 of the GNU
25
+ General Public License.
26
+
27
+ "The Library" refers to a covered work governed by this License,
28
+ other than an Application or a Combined Work as defined below.
29
+
30
+ An "Application" is any work that makes use of an interface provided
31
+ by the Library, but which is not otherwise based on the Library.
32
+ Defining a subclass of a class defined by the Library is deemed a mode
33
+ of using an interface provided by the Library.
34
+
35
+ A "Combined Work" is a work produced by combining or linking an
36
+ Application with the Library. The particular version of the Library
37
+ with which the Combined Work was made is also called the "Linked
38
+ Version".
39
+
40
+ The "Minimal Corresponding Source" for a Combined Work means the
41
+ Corresponding Source for the Combined Work, excluding any source code
42
+ for portions of the Combined Work that, considered in isolation, are
43
+ based on the Application, and not on the Linked Version.
44
+
45
+ The "Corresponding Application Code" for a Combined Work means the
46
+ object code and/or source code for the Application, including any data
47
+ and utility programs needed for reproducing the Combined Work from the
48
+ Application, but excluding the System Libraries of the Combined Work.
49
+
50
+ 1. Exception to Section 3 of the GNU GPL.
51
+
52
+ You may convey a covered work under sections 3 and 4 of this License
53
+ without being bound by section 3 of the GNU GPL.
54
+
55
+ 2. Conveying Modified Versions.
56
+
57
+ If you modify a copy of the Library, and, in your modifications, a
58
+ facility refers to a function or data to be supplied by an Application
59
+ that uses the facility (other than as an argument passed when the
60
+ facility is invoked), then you may convey a copy of the modified
61
+ version:
62
+
63
+ a) under this License, provided that you make a good faith effort to
64
+ ensure that, in the event an Application does not supply the
65
+ function or data, the facility still operates, and performs
66
+ whatever part of its purpose remains meaningful, or
67
+
68
+ b) under the GNU GPL, with none of the additional permissions of
69
+ this License applicable to that copy.
70
+
71
+ 3. Object Code Incorporating Material from Library Header Files.
72
+
73
+ The object code form of an Application may incorporate material from
74
+ a header file that is part of the Library. You may convey such object
75
+ code under terms of your choice, provided that, if the incorporated
76
+ material is not limited to numerical parameters, data structure
77
+ layouts and accessors, or small macros, inline functions and templates
78
+ (ten or fewer lines in length), you do both of the following:
79
+
80
+ a) Give prominent notice with each copy of the object code that the
81
+ Library is used in it and that the Library and its use are
82
+ covered by this License.
83
+
84
+ b) Accompany the object code with a copy of the GNU GPL and this license
85
+ document.
86
+
87
+ 4. Combined Works.
88
+
89
+ You may convey a Combined Work under terms of your choice that,
90
+ taken together, effectively do not restrict modification of the
91
+ portions of the Library contained in the Combined Work and reverse
92
+ engineering for debugging such modifications, if you also do each of
93
+ the following:
94
+
95
+ a) Give prominent notice with each copy of the Combined Work that
96
+ the Library is used in it and that the Library and its use are
97
+ covered by this License.
98
+
99
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
100
+ document.
101
+
102
+ c) For a Combined Work that displays copyright notices during
103
+ execution, include the copyright notice for the Library among
104
+ these notices, as well as a reference directing the user to the
105
+ copies of the GNU GPL and this license document.
106
+
107
+ d) Do one of the following:
108
+
109
+ 0) Convey the Minimal Corresponding Source under the terms of this
110
+ License, and the Corresponding Application Code in a form
111
+ suitable for, and under terms that permit, the user to
112
+ recombine or relink the Application with a modified version of
113
+ the Linked Version to produce a modified Combined Work, in the
114
+ manner specified by section 6 of the GNU GPL for conveying
115
+ Corresponding Source.
116
+
117
+ 1) Use a suitable shared library mechanism for linking with the
118
+ Library. A suitable mechanism is one that (a) uses at run time
119
+ a copy of the Library already present on the user's computer
120
+ system, and (b) will operate properly with a modified version
121
+ of the Library that is interface-compatible with the Linked
122
+ Version.
123
+
124
+ e) Provide Installation Information, but only if you would otherwise
125
+ be required to provide such information under section 6 of the
126
+ GNU GPL, and only to the extent that such information is
127
+ necessary to install and execute a modified version of the
128
+ Combined Work produced by recombining or relinking the
129
+ Application with a modified version of the Linked Version. (If
130
+ you use option 4d0, the Installation Information must accompany
131
+ the Minimal Corresponding Source and Corresponding Application
132
+ Code. If you use option 4d1, you must provide the Installation
133
+ Information in the manner specified by section 6 of the GNU GPL
134
+ for conveying Corresponding Source.)
135
+
136
+ 5. Combined Libraries.
137
+
138
+ You may place library facilities that are a work based on the
139
+ Library side by side in a single library together with other library
140
+ facilities that are not Applications and are not covered by this
141
+ License, and convey such a combined library under terms of your
142
+ choice, if you do both of the following:
143
+
144
+ a) Accompany the combined library with a copy of the same work based
145
+ on the Library, uncombined with any other library facilities,
146
+ conveyed under the terms of this License.
147
+
148
+ b) Give prominent notice with the combined library that part of it
149
+ is a work based on the Library, and explaining where to find the
150
+ accompanying uncombined form of the same work.
151
+
152
+ 6. Revised Versions of the GNU Lesser General Public License.
153
+
154
+ The Free Software Foundation may publish revised and/or new versions
155
+ of the GNU Lesser General Public License from time to time. Such new
156
+ versions will be similar in spirit to the present version, but may
157
+ differ in detail to address new problems or concerns.
158
+
159
+ Each version is given a distinguishing version number. If the
160
+ Library as you received it specifies that a certain numbered version
161
+ of the GNU Lesser General Public License "or any later version"
162
+ applies to it, you have the option of following the terms and
163
+ conditions either of that published version or of any later version
164
+ published by the Free Software Foundation. If the Library as you
165
+ received it does not specify a version number of the GNU Lesser
166
+ General Public License, you may choose any version of the GNU Lesser
167
+ General Public License ever published by the Free Software Foundation.
168
+
169
+ If the Library as you received it specifies that a proxy can decide
170
+ whether future versions of the GNU Lesser General Public License shall
171
+ apply, that proxy's public statement of acceptance of any version is
172
+ permanent authorization for you to choose that version for the
173
+ Library.
174
+
175
+ Project-URL: homepage, https://github.com/martinpitt/python-dbusmock
11
176
  Classifier: License :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)
12
177
  Classifier: Programming Language :: Python :: 3
13
178
  Classifier: Development Status :: 6 - Mature
@@ -19,8 +184,10 @@ Classifier: Topic :: Software Development :: Testing
19
184
  Classifier: Topic :: Software Development :: Testing :: Mocking
20
185
  Classifier: Topic :: Software Development :: Testing :: Unit
21
186
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
187
+ Requires-Python: >=3.8
22
188
  Description-Content-Type: text/markdown
23
189
  License-File: COPYING
190
+ Requires-Dist: dbus-python
24
191
 
25
192
  ![CI status](https://github.com/martinpitt/python-dbusmock/actions/workflows/tests.yml/badge.svg)
26
193
 
@@ -422,5 +589,3 @@ re-run all tests in the container shell like above. You can also run a specific
422
589
  test:
423
590
 
424
591
  python3 -m unittest tests.test_api.TestAPI.test_onearg_ret
425
-
426
-
@@ -1,4 +1,3 @@
1
- # coding: UTF-8
2
1
  """Mock D-Bus objects for test suites."""
3
2
 
4
3
  # This program is free software; you can redistribute it and/or modify it under
@@ -1,4 +1,3 @@
1
- # coding: UTF-8
2
1
  """Main entry point for running mock server."""
3
2
 
4
3
  # This program is free software; you can redistribute it and/or modify it under
@@ -0,0 +1 @@
1
+ __version__ = "0.34.0"
@@ -1,4 +1,3 @@
1
- # coding: UTF-8
2
1
  """Mock D-Bus objects for test suites."""
3
2
 
4
3
  # This program is free software; you can redistribute it and/or modify it under
@@ -199,6 +198,7 @@ class DBusMockObject(dbus.service.Object): # pylint: disable=too-many-instance-
199
198
  props: PropsType,
200
199
  logfile: Optional[str] = None,
201
200
  is_object_manager: bool = False,
201
+ mock_data: Any = None,
202
202
  ) -> None:
203
203
  """Create a new DBusMockObject
204
204
 
@@ -234,6 +234,7 @@ class DBusMockObject(dbus.service.Object): # pylint: disable=too-many-instance-
234
234
  self.logfile = open(logfile, "wb") if logfile else None # noqa: SIM115
235
235
  self.is_logfile_owner = True
236
236
  self.call_log: List[CallLogType] = []
237
+ self.mock_data = mock_data
237
238
 
238
239
  if props is None:
239
240
  props = {}
@@ -323,7 +324,9 @@ class DBusMockObject(dbus.service.Object): # pylint: disable=too-many-instance-
323
324
  )
324
325
 
325
326
  @dbus.service.method(MOCK_IFACE, in_signature="ssa{sv}a(ssss)", out_signature="")
326
- def AddObject(self, path: str, interface: str, properties: PropsType, methods: List[MethodType]) -> None:
327
+ def AddObject(
328
+ self, path: str, interface: str, properties: PropsType, methods: List[MethodType], **kwargs
329
+ ) -> None:
327
330
  """Dynamically add a new D-Bus object to the mock
328
331
 
329
332
  :param path: D-Bus object path
@@ -335,6 +338,12 @@ class DBusMockObject(dbus.service.Object): # pylint: disable=too-many-instance-
335
338
  methods to add to "interface"; see AddMethod() for details of
336
339
  the tuple values
337
340
 
341
+ Keyword Arguments:
342
+ :param mock_class: A DBusMockObject derived class name (this is only possible
343
+ when the method is not called via dbus)
344
+ :param mock_data: Additional data which will be passed to the DBusMockObject
345
+ constructor
346
+
338
347
  If this is a D-Bus ObjectManager instance, the InterfacesAdded signal
339
348
  will *not* be emitted for the object automatically; it must be emitted
340
349
  manually if desired. This is because AddInterface may be called after
@@ -352,13 +361,33 @@ class DBusMockObject(dbus.service.Object): # pylint: disable=too-many-instance-
352
361
  ('EchoInt', 'i', 'i', 'ret = args[0]'),
353
362
  ('GetClients', '', 'ao', 'ret = ["/com/example/Foo/Client1"]'),
354
363
  ])
364
+
365
+ Example 2 (in a template)::
366
+
367
+ class FooManager(dbusmock.mockobject.DBusMockObject):
368
+ def __init__(self, *args, **kwargs):
369
+ super(FooManager, self).__init__(*args, **kwargs)
370
+ self.magic = kwargs.get('mock_data')
371
+
372
+ @dbus.service.method('com.example.Foo.Control', in_signature='i', out_signature='i')
373
+ def EchoMagic(self, input):
374
+ return self.magic + input
375
+
376
+ dbus_proxy.AddObject('/com/example/Foo/Manager',
377
+ 'com.example.Foo.Control',
378
+ {}, [],
379
+ mock_class=FooManager,
380
+ mock_data=42)
355
381
  """
356
382
  if path in objects:
357
383
  raise dbus.exceptions.DBusException(
358
384
  f"object {path} already exists", name="org.freedesktop.DBus.Mock.NameError"
359
385
  )
360
386
 
361
- obj = DBusMockObject(self.bus_name, path, interface, properties)
387
+ mock_class = kwargs.get("mock_class", DBusMockObject)
388
+ mock_data = kwargs.get("mock_data")
389
+
390
+ obj = mock_class(self.bus_name, path, interface, properties, mock_data=mock_data)
362
391
  # make sure created objects inherit the log file stream
363
392
  obj.logfile = self.logfile
364
393
  obj.object_manager = self.object_manager
@@ -95,7 +95,7 @@ def RequestDefaultAgent(manager, agent_path):
95
95
  manager.default_agent = agent_path
96
96
 
97
97
 
98
- def load(mock, _parameters):
98
+ def load(mock, parameters):
99
99
  mock.AddObject(
100
100
  "/org/bluez",
101
101
  AGENT_MANAGER_IFACE,
@@ -120,9 +120,9 @@ def load(mock, _parameters):
120
120
  bluez.default_agent = None
121
121
 
122
122
  # whether to expose the LEAdvertisingManager1 interface on adapters (BLE advertising)
123
- bluez.enable_advertise_api = _parameters.get("enable_advertise_api", True)
123
+ bluez.enable_advertise_api = parameters.get("enable_advertise_api", True)
124
124
  # whether to expose the AdvertisementMonitorManager1 interface on adapters (Passive scanning)
125
- bluez.enable_monitor_api = _parameters.get("enable_monitor_api", True)
125
+ bluez.enable_monitor_api = parameters.get("enable_monitor_api", True)
126
126
 
127
127
 
128
128
  @dbus.service.method(ADAPTER_IFACE, in_signature="o", out_signature="")
@@ -0,0 +1,54 @@
1
+ """gsd-rfkill mock template
2
+
3
+ This creates the expected properties of the GNOME Settings Daemon's
4
+ rfkill object. You can specify any property such as AirplaneMode in
5
+ "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
20
+
21
+ SYSTEM_BUS = False
22
+ BUS_NAME = "org.gnome.SettingsDaemon.Rfkill"
23
+ MAIN_OBJ = "/org/gnome/SettingsDaemon/Rfkill"
24
+ MAIN_IFACE = "org.gnome.SettingsDaemon.Rfkill"
25
+
26
+
27
+ def load(mock, parameters):
28
+ props = dbus.Dictionary(
29
+ {
30
+ "AirplaneMode": parameters.get("AirplaneMode", False),
31
+ "BluetoothAirplaneMode": parameters.get("BluetoothAirplaneMode", False),
32
+ "BluetoothHardwareAirplaneMode": parameters.get("BluetoothHardwareAirplaneMode", False),
33
+ "BluetoothHasAirplaneMode": parameters.get("BluetoothHasAirplanemode", True),
34
+ "HardwareAirplaneMode": parameters.get("HardwareAirplaneMode", False),
35
+ "HasAirplaneMode": parameters.get("HasAirplaneMode", True),
36
+ "ShouldShowAirplaneMode": parameters.get("ShouldShowAirplaneMode", True),
37
+ "WwanAirplaneMode": parameters.get("WwanAirplaneMode", False),
38
+ "WwanHardwareAirplaneMode": parameters.get("WwanHardwareAirplaneMode", False),
39
+ "WwanHasAirplaneMode": parameters.get("WwanHasAirplaneMode", True),
40
+ },
41
+ signature="sv",
42
+ )
43
+ mock.AddProperties(MAIN_IFACE, props)
44
+
45
+
46
+ @dbus.service.method(MOCK_IFACE, in_signature="b", out_signature="b")
47
+ def SetAirplaneMode(self, mode):
48
+ """
49
+ Convenience method to toggle airplane mode
50
+ """
51
+ self.props[MAIN_IFACE]["AirplaneMode"] = mode
52
+ self.props[MAIN_IFACE]["BluetoothAirplaneMode"] = mode
53
+ self.props[MAIN_IFACE]["WwanAirplaneMode"] = mode
54
+ return mode
@@ -22,11 +22,14 @@ BUS_NAME = "org.freedesktop.ModemManager1"
22
22
  MAIN_OBJ = "/org/freedesktop/ModemManager1"
23
23
  MAIN_IFACE = "org.freedesktop.ModemManager1"
24
24
  SYSTEM_BUS = True
25
- IS_OBJECT_MANAGER = True
25
+ IS_OBJECT_MANAGER = False
26
26
  MODEM_IFACE = "org.freedesktop.ModemManager1.Modem"
27
27
  MODEM_3GPP_IFACE = "org.freedesktop.ModemManager1.Modem.Modem3gpp"
28
+ MODEM_CELL_BROADCAST_IFACE = "org.freedesktop.ModemManager1.Modem.CellBroadcast"
28
29
  MODEM_VOICE_IFACE = "org.freedesktop.ModemManager1.Modem.Voice"
29
30
  SIM_IFACE = "org.freedesktop.ModemManager1.Sim"
31
+ CBM_IFACE = "org.freedesktop.ModemManager1.Cbm"
32
+ SIMPLE_MODEM_PATH = "/org/freedesktop/ModemManager1/Modems/8"
30
33
 
31
34
 
32
35
  class MMModemMode:
@@ -118,6 +121,35 @@ def load(mock, parameters):
118
121
  mock.AddMethods(MAIN_IFACE, methods)
119
122
  mock.AddProperties(MAIN_IFACE, props)
120
123
 
124
+ cond = "k != '/'" if mock.path == "/" else f"k.startswith('{mock.path}/Modems/')"
125
+ code = f"ret = {{dbus.ObjectPath(k): objects[k].props for k in objects.keys() if {cond} }}"
126
+ mock.AddMethod(OBJECT_MANAGER_IFACE, "GetManagedObjects", "", "a{oa{sa{sv}}}", code)
127
+
128
+
129
+ def listCbm(_):
130
+ paths = []
131
+ for path in mockobject.objects:
132
+ if path.startswith("/org/freedesktop/ModemManager1/Cbm/"):
133
+ paths.append(dbus.ObjectPath(path))
134
+ return paths
135
+
136
+
137
+ def deleteCbm(self, cbm_path):
138
+ obj = mockobject.objects.get(cbm_path)
139
+ if obj is None:
140
+ return
141
+
142
+ modem_obj = mockobject.objects[SIMPLE_MODEM_PATH]
143
+ self.RemoveObject(cbm_path)
144
+ modem_obj.EmitSignal(
145
+ MODEM_CELL_BROADCAST_IFACE,
146
+ "Deleted",
147
+ "o",
148
+ [
149
+ cbm_path,
150
+ ],
151
+ )
152
+
121
153
 
122
154
  @dbus.service.method(MOCK_IFACE, in_signature="", out_signature="ss")
123
155
  def AddSimpleModem(self):
@@ -127,7 +159,7 @@ def AddSimpleModem(self):
127
159
 
128
160
  Returns the new object path.
129
161
  """
130
- modem_path = "/org/freedesktop/ModemManager1/Modems/8"
162
+ modem_path = SIMPLE_MODEM_PATH
131
163
  sim_path = "/org/freedesktop/ModemManager1/SIM/2"
132
164
  manager = mockobject.objects[MAIN_OBJ]
133
165
 
@@ -162,6 +194,16 @@ def AddSimpleModem(self):
162
194
  modem = mockobject.objects[modem_path]
163
195
  modem.AddProperties(MODEM_3GPP_IFACE, modem_3gpp_props)
164
196
 
197
+ modem_cell_broadcast_props = {
198
+ "CellBroadcasts": dbus.Array([], signature="o"),
199
+ }
200
+ modem_cell_broadcast_methods = [
201
+ ("List", "", "ao", listCbm),
202
+ ("Delete", "o", "", deleteCbm),
203
+ ]
204
+ modem.AddProperties(MODEM_CELL_BROADCAST_IFACE, modem_cell_broadcast_props)
205
+ modem.AddMethods(MODEM_CELL_BROADCAST_IFACE, modem_cell_broadcast_methods)
206
+
165
207
  modem_voice_props = {
166
208
  "Calls": dbus.Array([], signature="o"),
167
209
  "EmergencyOnly": False,
@@ -172,7 +214,6 @@ def AddSimpleModem(self):
172
214
  ("CallWaitingQuery", "", "b", "ret = self.call_waiting"),
173
215
  ("CallWaitingSetup", "b", "", "self.call_waiting = args[0]"),
174
216
  ]
175
- modem = mockobject.objects[modem_path]
176
217
  modem.AddProperties(MODEM_VOICE_IFACE, modem_voice_props)
177
218
  modem.AddMethods(MODEM_VOICE_IFACE, modem_voice_methods)
178
219
 
@@ -185,6 +226,7 @@ def AddSimpleModem(self):
185
226
  {
186
227
  MODEM_IFACE: modem_props,
187
228
  MODEM_3GPP_IFACE: modem_3gpp_props,
229
+ MODEM_CELL_BROADCAST_IFACE: modem_cell_broadcast_props,
188
230
  MODEM_VOICE_IFACE: modem_voice_props,
189
231
  },
190
232
  ],
@@ -196,14 +238,46 @@ def AddSimpleModem(self):
196
238
  "PreferredNetworks": dbus.Array([], signature="(su)"),
197
239
  }
198
240
  self.AddObject(sim_path, SIM_IFACE, sim_props, [])
199
- manager.EmitSignal(
200
- OBJECT_MANAGER_IFACE,
201
- "InterfacesAdded",
202
- "oa{sa{sv}}",
241
+
242
+ return (modem_path, sim_path)
243
+
244
+
245
+ @dbus.service.method(MOCK_IFACE, in_signature="uus", out_signature="s")
246
+ def AddCbm(self, state, channel, text):
247
+ """Convenience method to add a cell broadcast message
248
+
249
+ Returns the new object path.
250
+ """
251
+ n = 1
252
+ while mockobject.objects.get(f"/org/freedesktop/ModemManager1/Cbm/{n}") is not None:
253
+ n += 1
254
+ cbm_path = f"/org/freedesktop/ModemManager1/Cbm/{n}"
255
+
256
+ cbm_props = {
257
+ "State": dbus.UInt32(state),
258
+ "Channel": dbus.UInt32(channel),
259
+ "Text": dbus.String(text),
260
+ "MessageCode": dbus.UInt32(0),
261
+ "Update": dbus.UInt32(0),
262
+ }
263
+ self.AddObject(cbm_path, CBM_IFACE, cbm_props, [])
264
+
265
+ modem_obj = mockobject.objects[SIMPLE_MODEM_PATH]
266
+ paths = listCbm(self)
267
+ modem_obj.UpdateProperties(
268
+ MODEM_CELL_BROADCAST_IFACE,
269
+ {
270
+ "CellBroadcasts": dbus.Array(paths),
271
+ },
272
+ )
273
+
274
+ modem_obj.EmitSignal(
275
+ MODEM_CELL_BROADCAST_IFACE,
276
+ "Added",
277
+ "o",
203
278
  [
204
- dbus.ObjectPath(sim_path),
205
- {SIM_IFACE: sim_props},
279
+ dbus.ObjectPath(cbm_path),
206
280
  ],
207
281
  )
208
282
 
209
- return (modem_path, sim_path)
283
+ return cbm_path
@@ -196,7 +196,7 @@ def AddChargingBattery(self, device_name, model_name, percentage, seconds_to_ful
196
196
  @dbus.service.method(MOCK_IFACE, in_signature="uuddddxxbsu", out_signature="")
197
197
  def SetupDisplayDevice(
198
198
  self,
199
- _type,
199
+ _type, # noqa: RUF052, RUF100 (access to local dummy variable); but this is API now
200
200
  state,
201
201
  percentage,
202
202
  energy,
@@ -321,7 +321,7 @@ class DBusTestCase(unittest.TestCase):
321
321
  argv.append("--config-file=" + str(conf))
322
322
  else:
323
323
  argv.append("--session")
324
- lines = subprocess.check_output(argv, universal_newlines=True).strip().splitlines()
324
+ lines = subprocess.check_output(argv, text=True).strip().splitlines()
325
325
  assert len(lines) == 2, "expected exactly 2 lines of output from dbus-daemon"
326
326
  # usually the first line is the address, but be lenient and accept any order
327
327
  try:
@@ -10,13 +10,14 @@ downstream_package_name: python-dbusmock
10
10
 
11
11
  actions:
12
12
  create-archive:
13
- - ./setup.py sdist
13
+ - python3 -m build --sdist
14
14
  # spec and tarball need to be in the same directory
15
- - sh -c 'mv dist/*.tar.* packaging; ls packaging/python[-_]dbusmock-*.tar.*'
15
+ - sh -c 'mv dist/*.tar.* packaging; ls packaging/python_dbusmock-*.tar.*'
16
16
 
17
17
  srpm_build_deps:
18
- - python3-setuptools
18
+ - python3-build
19
19
  - python3-setuptools_scm
20
+ - python3dist(wheel)
20
21
 
21
22
  jobs:
22
23
  - job: copr_build
@@ -24,16 +25,14 @@ jobs:
24
25
  targets:
25
26
  - fedora-all
26
27
  - centos-stream-9-x86_64
27
- # FIXME: broken
28
- # - centos-stream-10-x86_64
28
+ - centos-stream-10-x86_64
29
29
 
30
30
  - job: tests
31
31
  trigger: pull_request
32
32
  targets:
33
33
  - fedora-all
34
34
  - centos-stream-9-x86_64
35
- # FIXME: broken rpm build above
36
- # - centos-stream-10-x86_64
35
+ - centos-stream-10-x86_64
37
36
 
38
37
  - job: propose_downstream
39
38
  trigger: release
@@ -24,7 +24,7 @@ classifiers = [
24
24
  "Topic :: Software Development :: Libraries :: Python Modules",
25
25
  ]
26
26
  dynamic = ["version"]
27
- requires-python = ">=3.6"
27
+ requires-python = ">=3.8"
28
28
 
29
29
  dependencies = ["dbus-python"]
30
30
 
@@ -43,7 +43,7 @@ version_scheme = 'post-release'
43
43
 
44
44
  [tool.pylint]
45
45
  format = { max-line-length = 130 }
46
- "messages control" = { disable = ["invalid-name"] }
46
+ "messages control" = { disable = ["invalid-name", "too-many-arguments", "too-many-positional-arguments"] }
47
47
  design = { max-args = 7, max-locals = 25, max-public-methods = 25 }
48
48
 
49
49
  [tool.mypy]