logind template doesn't properly add its properties

Bug #1348437 reported by Philip Chimento
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-dbusmock
Fix Released
Undecided
Unassigned
python-dbusmock (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

When instantiating a logind template with spawn_server_template(), you will see this log message:

ERROR:dbus.service:Unable to append ({'IdleAction': 'ignore', 'PreparingForSleep': False, 'IdleHint': False, 'IdleSinceHint': None, 'PreparingForShutdown': False},) to message with signature a{sv}: <type 'exceptions.TypeError'>: Don't know which D-Bus type to use to encode type "NoneType"

This should be fixed by changing None to 0 on line 70 of logind.py: https://gitorious.org/python-dbusmock/python-dbusmock/source/fe9c838adbb0e1d4b85f566ec0d48ff5584f70c3:dbusmock/templates/logind.py#L70

It can be worked around by specifying parameters={'IdleSinceHint': 0} to the spawn_server_template() call.

Revision history for this message
Martin Pitt (pitti) wrote :

Thanks for pointing out! Fixed in https://gitorious.org/python-dbusmock/python-dbusmock/commit/3be081b2

But OOI, I don't see that error message, neither in the test suite nor when instantiating it manually with

  DBUS_SYSTEM_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS python3 -m dbusmock -t logind
  DBUS_SYSTEM_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS loginctl

How did you trigger this? I'd like to reproduce that in a test case.

Thanks!

Changed in python-dbusmock:
status: New → Fix Committed
Revision history for this message
Philip Chimento (philip-chimento) wrote :

Thanks for fixing! This test case triggers it for me:

import dbus
import unittest

import dbusmock

class Test(dbusmock.DBusTestCase):
    @classmethod
    def setUpClass(klass):
        """Set up a mock system bus."""
        klass.start_system_bus()
        klass.dbus_con = klass.get_dbus(system_bus=True)

    def setUp(self):
        (self.login_popen, self.login_obj) = self.spawn_server_template('logind')

    def tearDown(self):
        self.login_popen.terminate()
        self.login_popen.wait()

    def test_case_for_bug(self):
        iface = dbus.Interface(self.dbus_con.get_object('org.freedesktop.login1',
            '/org/freedesktop/login1'), 'org.freedesktop.DBus.Properties')
        iface.GetAll('org.freedesktop.login1.Manager')

if __name__ == '__main__':
    unittest.main()

Revision history for this message
Philip Chimento (philip-chimento) wrote :

By the way, on your fix it looks like you might have mistakenly assigned all three property default values to IdleSinceHint.

Revision history for this message
Martin Pitt (pitti) wrote :

Argh, I'm a copy&paste muppet. Fixed in https://gitorious.org/python-dbusmock/python-dbusmock/commit/6378ffb07, thanks for pointing out! Will add the test case on Monday.

Revision history for this message
Martin Pitt (pitti) wrote :
Revision history for this message
Philip Chimento (philip-chimento) wrote :

Awesome!

Revision history for this message
Martin Pitt (pitti) wrote :
Changed in python-dbusmock:
status: Fix Committed → Fix Released
Changed in python-dbusmock (Ubuntu):
status: New → Fix Committed
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package python-dbusmock - 0.11.1-1

---------------
python-dbusmock (0.11.1-1) unstable; urgency=medium

  * New upstream release:
    - logind template: Fix type of IdleSinceHint property, and add
      IdleSinceHintMonotonic and IdleActionUSec properties. (LP: #1348437)
    - NetworkManager template: Add "Devices" and "AccessPoints" properties of
      NetworkManager 0.9.10. (LP: #1328579)

 -- Martin Pitt <email address hidden> Fri, 08 Aug 2014 08:17:34 +0200

Changed in python-dbusmock (Ubuntu):
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.