+ python-dbusmock-0.22.0-1

Update to 0.22.0
This commit is contained in:
Bastien Nocera 2021-02-12 13:59:24 +01:00
parent 782c023b70
commit adb6b71cbf
4 changed files with 8 additions and 135 deletions

1
.gitignore vendored
View File

@ -15,3 +15,4 @@
/python-dbusmock-0.16.9.tar.gz /python-dbusmock-0.16.9.tar.gz
/python-dbusmock-0.17.tar.gz /python-dbusmock-0.17.tar.gz
/python-dbusmock-0.18.3.tar.gz /python-dbusmock-0.18.3.tar.gz
/python-dbusmock-0.22.0.tar.gz

View File

@ -1,130 +0,0 @@
From 157499e2f07e6cf77e6ddd1619a55932809f99cb Mon Sep 17 00:00:00 2001
From: Bastien Nocera <hadess@hadess.net>
Date: Thu, 14 Nov 2019 14:09:44 +0100
Subject: [PATCH] Add mock server for low-memory-monitor
API version 2.0
https://gitlab.freedesktop.org/hadess/low-memory-monitor/
---
dbusmock/templates/low_memory_monitor.py | 38 +++++++++++++++
tests/test_low_memory_monitor.py | 62 ++++++++++++++++++++++++
2 files changed, 100 insertions(+)
create mode 100644 dbusmock/templates/low_memory_monitor.py
create mode 100644 tests/test_low_memory_monitor.py
diff --git a/dbusmock/templates/low_memory_monitor.py b/dbusmock/templates/low_memory_monitor.py
new file mode 100644
index 0000000..bb9a757
--- /dev/null
+++ b/dbusmock/templates/low_memory_monitor.py
@@ -0,0 +1,38 @@
+'''low-memory-monitor mock template
+
+This creates the expected methods and properties of the main
+org.freedesktop.LowMemoryMonitor object.
+
+This provides only the 2.0 D-Bus API of low-memory-monitor.
+'''
+
+# This program is free software; you can redistribute it and/or modify it under
+# the terms of the GNU Lesser General Public License as published by the Free
+# Software Foundation; either version 3 of the License, or (at your option) any
+# later version. See http://www.gnu.org/copyleft/lgpl.html for the full text
+# of the license.
+
+__author__ = 'Bastien Nocera'
+__email__ = 'hadess@hadess.net'
+__copyright__ = '(c) 2019, Red Hat Inc.'
+__license__ = 'LGPL 3+'
+
+import dbus
+
+from dbusmock import MOCK_IFACE, mockobject
+import dbusmock
+
+BUS_NAME = 'org.freedesktop.LowMemoryMonitor'
+MAIN_OBJ = '/org/freedesktop/LowMemoryMonitor'
+MAIN_IFACE = 'org.freedesktop.LowMemoryMonitor'
+SYSTEM_BUS = True
+
+
+def load(mock, parameters):
+ # Loaded!
+ mock.loaded = True
+
+@dbus.service.method(MOCK_IFACE,
+ in_signature='y', out_signature='')
+def EmitWarning(self, state):
+ self.EmitSignal(MAIN_IFACE, 'LowMemoryWarning', 'y', [dbus.Byte(state)])
diff --git a/tests/test_low_memory_monitor.py b/tests/test_low_memory_monitor.py
new file mode 100644
index 0000000..b4b1fd7
--- /dev/null
+++ b/tests/test_low_memory_monitor.py
@@ -0,0 +1,62 @@
+#!/usr/bin/python3
+
+# This program is free software; you can redistribute it and/or modify it under
+# the terms of the GNU Lesser General Public License as published by the Free
+# Software Foundation; either version 3 of the License, or (at your option) any
+# later version. See http://www.gnu.org/copyleft/lgpl.html for the full text
+# of the license.
+
+__author__ = 'Bastien Nocera'
+__email__ = 'hadess@hadess.net'
+__copyright__ = '(c) 2019 Red Hat Inc.'
+__license__ = 'LGPL 3+'
+
+import unittest
+import sys
+import subprocess
+import dbus
+import dbus.mainloop.glib
+import dbusmock
+import fcntl
+import os
+
+from gi.repository import GLib
+
+dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
+
+class TestLowMemoryMonitor(dbusmock.DBusTestCase):
+ '''Test mocking gnome-screensaver'''
+
+ @classmethod
+ def setUpClass(klass):
+ klass.start_system_bus()
+ klass.dbus_con = klass.get_dbus(True)
+
+ def setUp(self):
+ (self.p_mock, self.obj_lmm) = self.spawn_server_template(
+ 'low_memory_monitor', {}, stdout=subprocess.PIPE)
+ # set log to nonblocking
+ flags = fcntl.fcntl(self.p_mock.stdout, fcntl.F_GETFL)
+ fcntl.fcntl(self.p_mock.stdout, fcntl.F_SETFL, flags | os.O_NONBLOCK)
+ self.last_warning = -1
+ self.dbusmock = dbus.Interface(self.obj_lmm, dbusmock.MOCK_IFACE)
+
+ def tearDown(self):
+ self.p_mock.terminate()
+ self.p_mock.wait()
+
+ def test_low_memory_warning_signal(self):
+ '''LowMemoryWarning signal'''
+
+ self.dbusmock.EmitWarning(100)
+ log = self.p_mock.stdout.read()
+ self.assertRegex(log, b'[0-9.]+ emit .*LowMemoryWarning 100\n')
+
+ self.dbusmock.EmitWarning(255)
+ log = self.p_mock.stdout.read()
+ self.assertRegex(log, b'[0-9.]+ emit .*LowMemoryWarning 255\n')
+
+
+if __name__ == '__main__':
+ # avoid writing to stderr
+ unittest.main(testRunner=unittest.TextTestRunner(stream=sys.stdout, verbosity=2))
--
2.21.0

View File

@ -1,15 +1,13 @@
%global modname dbusmock %global modname dbusmock
Name: python-%{modname} Name: python-%{modname}
Version: 0.18.3 Version: 0.22.0
Release: 6%{?dist} Release: 1%{?dist}
Summary: Mock D-Bus objects Summary: Mock D-Bus objects
License: LGPLv3+ License: LGPLv3+
URL: https://pypi.python.org/pypi/python-dbusmock URL: https://pypi.python.org/pypi/python-dbusmock
Source0: https://files.pythonhosted.org/packages/source/p/%{name}/%{name}-%{version}.tar.gz Source0: https://files.pythonhosted.org/packages/source/p/%{name}/%{name}-%{version}.tar.gz
# From https://github.com/martinpitt/python-dbusmock/pull/54
Patch0: 0001-Add-mock-server-for-low-memory-monitor.patch
BuildArch: noarch BuildArch: noarch
BuildRequires: git BuildRequires: git
@ -55,6 +53,10 @@ rm -rf python-%{modname}.egg-info
%{python3_sitelib}/*%{modname}* %{python3_sitelib}/*%{modname}*
%changelog %changelog
* Fri Feb 12 2021 Bastien Nocera <bnocera@redhat.com> - 0.22.0-1
+ python-dbusmock-0.22.0-1
- Update to 0.22.0
* Wed Jan 27 2021 Fedora Release Engineering <releng@fedoraproject.org> - 0.18.3-6 * Wed Jan 27 2021 Fedora Release Engineering <releng@fedoraproject.org> - 0.18.3-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild - Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild

View File

@ -1 +1 @@
SHA512 (python-dbusmock-0.18.3.tar.gz) = 6f7b42eae578ce03024b3b5cc85e82f04a467803f4c8b4cb5193454dcd849038f11e6ce5028ca9dd57ea5a9380c1b754d8fc644b4a24b51deee9e87b409115c3 SHA512 (python-dbusmock-0.22.0.tar.gz) = 2c3430f4178a16acc376ce582f4a1a9bbe8b917efcd7eee58dab85ee3addf60ba355ae9e7b318ec2cdf7ca771183c37d16520a1e5bcab8414c66e2d2a36d26fe