Compare commits

...

No commits in common. "c8" and "c9s" have entirely different histories.
c8 ... c9s

12 changed files with 139 additions and 229 deletions

1
.fmf/version Normal file
View File

@ -0,0 +1 @@
1

12
.gitignore vendored
View File

@ -1 +1,11 @@
SOURCES/dasbus-1.2.tar.gz /dasbus-0.1.tar.gz
/dasbus-0.2.tar.gz
/dasbus-0.3.tar.gz
/dasbus-0.4.tar.gz
/dasbus-1.0.tar.gz
/dasbus-1.1.tar.gz
/dasbus-1.2.tar.gz
/dasbus-1.3.tar.gz
/dasbus-1.4.tar.gz
/dasbus-1.5.tar.gz
/dasbus-1.7.tar.gz

35
.packit.yaml Normal file
View File

@ -0,0 +1,35 @@
specfile_path: python-dasbus.spec
downstream_package_name: python-dasbus
actions:
get-current-version:
- "python3 ./setup.py --version"
create-archive:
- "make BUILD_ARGS=sdist archive"
- 'bash -c "cp dist/*.tar.gz ."'
- 'bash -c "ls *.tar.gz"'
jobs:
- job: copr_build
trigger: pull_request
metadata:
targets:
- fedora-all
- job: copr_build
trigger: commit
metadata:
targets:
- fedora-rawhide
branch: master
owner: "@rhinstaller"
project: Anaconda
preserve_project: True
- job: copr_build
trigger: commit
metadata:
targets:
- fedora-latest
branch: master
owner: "@rhinstaller"
project: Anaconda-devel
preserve_project: True

View File

@ -1 +0,0 @@
2e4a97b5620f67a2575b54dd3d434b657a14c099 SOURCES/dasbus-1.2.tar.gz

3
README.md Normal file
View File

@ -0,0 +1,3 @@
# python-dasbus
The python-dasbus package

3
README.packit Normal file
View File

@ -0,0 +1,3 @@
This repository is maintained by packit.
https://packit.dev/
The file was generated using packit 1.11.0.

View File

@ -1,64 +0,0 @@
From 14c059135e305f85a579acd449f3a1c893558e55 Mon Sep 17 00:00:00 2001
From: Vendula Poncova <vponcova@redhat.com>
Date: Thu, 16 Jul 2020 21:28:18 +0200
Subject: [PATCH 1/2] Fix tests for handling DBus errors on the server side
Really check the name and the message of every returned DBus error.
---
tests/test_server.py | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/tests/test_server.py b/tests/test_server.py
index d96144e..ce91b97 100644
--- a/tests/test_server.py
+++ b/tests/test_server.py
@@ -94,7 +94,10 @@ class DBusServerTestCase(unittest.TestCase):
parameters
)
- invocation.return_dbus_error(error_name, error_message)
+ invocation.return_dbus_error.assert_called_once_with(
+ error_name,
+ error_message
+ )
invocation.return_value.assert_not_called()
def test_register(self):
@@ -171,8 +174,8 @@ class DBusServerTestCase(unittest.TestCase):
"Interface",
"MethodInvalid",
error_name="not.known.Error.DBusSpecificationError",
- error_message="Unknown member MethodInvalid of "
- "the interface Interface."
+ error_message="DBus specification has no member "
+ "'Interface.MethodInvalid'."
)
self.error_mapper.add_rule(ErrorRule(
@@ -238,8 +241,9 @@ class DBusServerTestCase(unittest.TestCase):
"Property2",
get_variant("s", "World")
)),
- error_name="not.known.AttributeError",
- error_message="Property2 of Interface is not writable."
+ error_name="not.known.Error.AttributeError",
+ error_message="The property Interface.Property2 "
+ "is not writable."
)
self.assertEqual(self.object.Property2, "Hello")
@@ -250,8 +254,9 @@ class DBusServerTestCase(unittest.TestCase):
"Interface",
"Property3"
)),
- error_name="not.known.AttributeError",
- error_message="Property3 of Interface is not readable."
+ error_name="not.known.Error.AttributeError",
+ error_message="The property Interface.Property3 "
+ "is not readable."
)
self._call_method(
"org.freedesktop.DBus.Properties", "Set",
--
2.26.2

View File

@ -1,152 +0,0 @@
From e3c082e3619ab2d9095b58e55c90157f6376fd1e Mon Sep 17 00:00:00 2001
From: Vendula Poncova <vponcova@redhat.com>
Date: Thu, 16 Jul 2020 20:24:25 +0200
Subject: [PATCH 2/2] Handle all errors of the DBus call
Don't handle only errors caused by the method invocation, but handle
also errors caused by processing the result of the method.
---
dasbus/client/handler.py | 3 +--
dasbus/server/handler.py | 11 +++++------
tests/test_client.py | 16 ++++++++++++++++
tests/test_server.py | 36 ++++++++++++++++++++++++++++++------
4 files changed, 52 insertions(+), 14 deletions(-)
diff --git a/dasbus/client/handler.py b/dasbus/client/handler.py
index ed1a690..839f5a6 100644
--- a/dasbus/client/handler.py
+++ b/dasbus/client/handler.py
@@ -472,10 +472,9 @@ class ClientObjectHandler(AbstractClientObjectHandler):
"""
try:
result = call(*args, **kwargs)
+ return self._handle_method_result(result)
except Exception as error: # pylint: disable=broad-except
return self._handle_method_error(error)
- else:
- return self._handle_method_result(result)
def _handle_method_error(self, error):
"""Handle an error of a DBus call.
diff --git a/dasbus/server/handler.py b/dasbus/server/handler.py
index 3871948..8183f26 100644
--- a/dasbus/server/handler.py
+++ b/dasbus/server/handler.py
@@ -420,6 +420,11 @@ class ServerObjectHandler(AbstractServerObjectHandler):
method_name,
*unwrap_variant(parameters)
)
+ self._handle_method_result(
+ invocation,
+ member,
+ result
+ )
except Exception as error: # pylint: disable=broad-except
self._handle_method_error(
invocation,
@@ -427,12 +432,6 @@ class ServerObjectHandler(AbstractServerObjectHandler):
method_name,
error
)
- else:
- self._handle_method_result(
- invocation,
- member,
- result
- )
def _handle_method_error(self, invocation, interface_name, method_name,
error):
diff --git a/tests/test_client.py b/tests/test_client.py
index 7cb96c3..cd44552 100644
--- a/tests/test_client.py
+++ b/tests/test_client.py
@@ -256,6 +256,22 @@ class DBusClientTestCase(unittest.TestCase):
str(cm.exception)
)
+ def test_invalid_method_result(self):
+ """Test a method proxy with an invalid result."""
+ self._create_proxy("""
+ <node>
+ <interface name="Interface">
+ <method name="Method">
+ <arg direction="out" name="return" type="t"/>
+ </method>
+ </interface>
+ </node>
+ """)
+
+ self._set_reply(get_variant("i", -1))
+ with self.assertRaises(TypeError):
+ self.proxy.Method()
+
def _set_reply(self, reply_value):
"""Set the reply of the DBus call."""
self.connection.call_sync.reset_mock()
diff --git a/tests/test_server.py b/tests/test_server.py
index ce91b97..4adcf89 100644
--- a/tests/test_server.py
+++ b/tests/test_server.py
@@ -82,8 +82,8 @@ class DBusServerTestCase(unittest.TestCase):
def _call_method_with_error(self, interface, method,
parameters=NO_PARAMETERS,
- error_name="",
- error_message=""):
+ error_name=None,
+ error_message=None):
invocation = Mock()
with self.assertLogs(level='WARN'):
@@ -94,12 +94,17 @@ class DBusServerTestCase(unittest.TestCase):
parameters
)
- invocation.return_dbus_error.assert_called_once_with(
- error_name,
- error_message
- )
+ invocation.return_dbus_error.assert_called_once()
invocation.return_value.assert_not_called()
+ (name, msg), kwargs = invocation.return_dbus_error.call_args
+
+ self.assertEqual(kwargs, {})
+ self.assertEqual(name, error_name, "Unexpected error name.")
+
+ if error_message is not None:
+ self.assertEqual(msg, error_message, "Unexpected error message.")
+
def test_register(self):
"""Test the object registration."""
with self.assertRaises(DBusSpecificationError) as cm:
@@ -193,6 +198,25 @@ class DBusServerTestCase(unittest.TestCase):
error_message="The method has failed."
)
+ def test_invalid_method_result(self):
+ """Test a method with an invalid result."""
+ self._publish_object("""
+ <node>
+ <interface name="Interface">
+ <method name="Method">
+ <arg direction="out" name="return" type="t"/>
+ </method>
+ </interface>
+ </node>
+ """)
+
+ self.object.Method.return_value = -1
+ self._call_method_with_error(
+ "Interface",
+ "Method",
+ error_name="not.known.Error.OverflowError"
+ )
+
def test_property(self):
"""Test the property publishing."""
self._publish_object("""
--
2.26.2

6
gating.yaml Normal file
View File

@ -0,0 +1,6 @@
--- !Policy
product_versions:
- rhel-9
decision_context: osci_compose_gate
rules:
- !PassingTestCaseRule {test_case_name: osci.brew-build.tier0.functional}

29
plans/tests.fmf Normal file
View File

@ -0,0 +1,29 @@
summary: Standard tests for dasbus
prepare:
how: install
package:
- python3
- python3-dasbus
- dbus-daemon
discover:
how: shell
dist-git-source: true
dist-git-install-builddeps: true
tests:
- name: upstream test suite
test: |
set -x
if [ -z "$PKG_VER" ]; then
PKG_VER=`rpmspec -q --srpm --qf "%{version}" python-dasbus.spec`
fi
if [ -z "$PKG_VER" ]; then
echo "Error: Unable to extract package version"
exit 1
fi
pushd $TMT_SOURCE_DIR/dasbus-${PKG_VER}
dasbus_path=$(find /usr/ -path */site-packages | tr '\n' ':')
PYTHONPATH=$dasbus_path python3 -m unittest discover -v -s ./tests/
execute:
- how: tmt

View File

@ -1,21 +1,21 @@
%global srcname dasbus %global srcname dasbus
Name: python-%{srcname} Name: python-%{srcname}
Version: 1.2 Version: 1.7
Release: 2%{?dist} Release: 1%{?dist}
Summary: DBus library in Python 3 Summary: DBus library in Python 3
License: LGPLv2+ License: LGPL-2.1-or-later
URL: https://pypi.python.org/pypi/dasbus URL: https://pypi.python.org/pypi/dasbus
%if %{defined suse_version}
Source0: %{srcname}-%{version}.tar.gz
Group: Development/Libraries/Python
%else
Source0: %{pypi_source} Source0: %{pypi_source}
%endif
BuildArch: noarch BuildArch: noarch
# Handle all errors of the DBus call
# https://bugzilla.redhat.com/show_bug.cgi?id=1858757
Patch0: 0001-Fix-tests-for-handling-DBus-errors-on-the-server-sid.patch
Patch1: 0002-Handle-all-errors-of-the-DBus-call.patch
%global _description %{expand: %global _description %{expand:
Dasbus is a DBus library written in Python 3, based on Dasbus is a DBus library written in Python 3, based on
GLib and inspired by pydbus. It is designed to be easy GLib and inspired by pydbus. It is designed to be easy
@ -27,19 +27,28 @@ to use and extend.}
Summary: %{summary} Summary: %{summary}
BuildRequires: python3-devel BuildRequires: python3-devel
BuildRequires: python3-setuptools BuildRequires: python3-setuptools
%if %{defined suse_version}
BuildRequires: fdupes
BuildRequires: python-rpm-macros
Requires: python3-gobject
%else
Requires: python3-gobject-base Requires: python3-gobject-base
%endif
%{?python_provide:%python_provide python3-%{srcname}} %{?python_provide:%python_provide python3-%{srcname}}
%description -n python3-%{srcname} %{_description} %description -n python3-%{srcname} %{_description}
%prep %prep
%autosetup -n %{srcname}-%{version} -p1 %autosetup -n %{srcname}-%{version}
%build %build
%py3_build %py3_build
%install %install
%py3_install %py3_install
%if %{defined suse_version}
%python_expand %fdupes %{buildroot}%{python3_sitelib}
%endif
%files -n python3-%{srcname} %files -n python3-%{srcname}
%license LICENSE %license LICENSE
@ -48,8 +57,38 @@ Requires: python3-gobject-base
%{python3_sitelib}/%{srcname}/ %{python3_sitelib}/%{srcname}/
%changelog %changelog
* Mon Jul 27 2020 Vendula Poncova <vponcova@redhat.com> - 1.2-2 * Fri Sep 12 2025 Katerina Koukiou <k.koukiou@gmail.com> - 1.7-1
- Handle all errors of the DBus call (#1858757) (vponcova) - Update to version 1.7
* Mon Jul 07 2025 Katerina Koukiou <k.koukiou@gmail.com> - 1.5-1
- Update to version 1.5
* Tue Aug 10 2021 Mohan Boddu <mboddu@redhat.com> - 1.4-5
- Rebuilt for IMA sigs, glibc 2.34, aarch64 flags
Related: rhbz#1991688
* Fri Apr 16 2021 Mohan Boddu <mboddu@redhat.com> - 1.4-4
- Rebuilt for RHEL 9 BETA on Apr 15th 2021. Related: rhbz#1947937
* Wed Jan 27 2021 Fedora Release Engineering <releng@fedoraproject.org> - 1.4-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild
* Wed Jul 29 2020 Fedora Release Engineering <releng@fedoraproject.org> - 1.4-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild
* Fri Jul 24 2020 Vendula Poncova <vponcova@redhat.com> - 1.4-1
- Handle all errors of the DBus call (vponcova)
- Fix tests for handling DBus errors on the server side (vponcova)
- Run packit smoke tests for all Fedora (jkonecny)
- Fix packit archive creation (jkonecny)
- Add possibility to change setup.py arguments (jkonecny)
* Wed Jun 17 2020 Vendula Poncova <vponcova@redhat.com> - 1.3-1
- Document differences between dasbus and pydbus (vponcova)
- Improve the support for interface proxies in the service identifier (vponcova)
- Improve the support for interface proxies in the message bus (vponcova)
- Test the interface proxies (vponcova)
- Make the message bus of a service identifier accessible (vponcova)
- Fix the testing environment for Fedora Rawhide (vponcova)
* Mon May 18 2020 Vendula Poncova <vponcova@redhat.com> - 1.2-1 * Mon May 18 2020 Vendula Poncova <vponcova@redhat.com> - 1.2-1
- Replace ABC with ABCMeta (vponcova) - Replace ABC with ABCMeta (vponcova)
- Fix typing tests (vponcova) - Fix typing tests (vponcova)

1
sources Normal file
View File

@ -0,0 +1 @@
SHA512 (dasbus-1.7.tar.gz) = ccf575d28d91ad96de78b8122eaf247182d22cee701859b1da83b2de2793362f164fe609187e8a9586083c55d985d95b6980b9ec291cb10d41d74dec03d8a873