dbusmock.templates.upower

upowerd mock template

This creates the expected methods and properties of the main org.freedesktop.UPower object, but no devices. You can specify any property such as ‘OnLowBattery’ or the return value of ‘SuspendAllowed’, ‘HibernateAllowed’, and ‘GetCriticalAction’ in “parameters”.

This provides the 1.0 D-Bus API of upower.

Attributes

__author__

__copyright__

BUS_NAME

MAIN_OBJ

MAIN_IFACE

SYSTEM_BUS

DEVICE_IFACE

Functions

load(mock, parameters)

AddAC(self, device_name, model_name)

Convenience method to add an AC object

AddDischargingBattery(self, device_name, model_name, ...)

Convenience method to add a discharging battery object

AddChargingBattery(self, device_name, model_name, ...)

Convenience method to add a charging battery object

SetupDisplayDevice(self, _type, state, percentage, ...)

Convenience method to configure DisplayDevice properties

SetDeviceProperties(_self, object_path, properties)

Convenience method to Set a device's properties.

RemoveDevice(self, device_path)

Module Contents

dbusmock.templates.upower.__author__ = 'Martin Pitt'[source]
Show Value
"""
(c) 2012, 2013 Canonical Ltd.
(c) 2017 - 2022 Martin Pitt <martin@piware.de>
"""
dbusmock.templates.upower.BUS_NAME = 'org.freedesktop.UPower'[source]
dbusmock.templates.upower.MAIN_OBJ = '/org/freedesktop/UPower'[source]
dbusmock.templates.upower.MAIN_IFACE = 'org.freedesktop.UPower'[source]
dbusmock.templates.upower.SYSTEM_BUS = True[source]
dbusmock.templates.upower.DEVICE_IFACE = 'org.freedesktop.UPower.Device'[source]
dbusmock.templates.upower.load(mock, parameters)[source]
dbusmock.templates.upower.AddAC(self, device_name, model_name)[source]

Convenience method to add an AC object

You have to specify a device name which must be a valid part of an object path, e. g. “mock_ac”, and an arbitrary model name.

Please note that this does not set any global properties such as “on-battery”.

Returns the new object path.

dbusmock.templates.upower.AddDischargingBattery(self, device_name, model_name, percentage, seconds_to_empty)[source]

Convenience method to add a discharging battery object

You have to specify a device name which must be a valid part of an object path, e. g. “mock_ac”, an arbitrary model name, the charge percentage, and the seconds until the battery is empty.

Please note that this does not set any global properties such as “on-battery”.

Returns the new object path.

dbusmock.templates.upower.AddChargingBattery(self, device_name, model_name, percentage, seconds_to_full)[source]

Convenience method to add a charging battery object

You have to specify a device name which must be a valid part of an object path, e. g. “mock_ac”, an arbitrary model name, the charge percentage, and the seconds until the battery is full.

Please note that this does not set any global properties such as “on-battery”.

Returns the new object path.

dbusmock.templates.upower.SetupDisplayDevice(self, _type, state, percentage, energy, energy_full, energy_rate, time_to_empty, time_to_full, is_present, icon_name, warning_level)[source]

Convenience method to configure DisplayDevice properties

This calls Set() for all properties that the DisplayDevice is defined to have, and is shorter if you have to completely set it up instead of changing just one or two properties.

dbusmock.templates.upower.SetDeviceProperties(_self, object_path, properties)[source]

Convenience method to Set a device’s properties.

object_path: the device to update properties: dictionary of keys to dbus variants.

Changing this property will trigger the device’s PropertiesChanged signal.

dbusmock.templates.upower.RemoveDevice(self, device_path)[source]