| 1 |
'''CHANGEME mock template |
| 2 |
|
| 3 |
This creates the expected methods and properties of the main |
| 4 |
CHANGEME object, but no devices. You can specify any property |
| 5 |
such as CHANGEME in "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__ = 'CHANGEME' |
| 15 |
__copyright__ = 'CHANGEME' |
| 16 |
|
| 17 |
import dbus |
| 18 |
|
| 19 |
from dbusmock import MOCK_IFACE |
| 20 |
|
| 21 |
# False for session bus, True for system bus; if not present, the bus has to be |
| 22 |
# specified in the spawn_server_template() call |
| 23 |
SYSTEM_BUS = True # CHANGEME |
| 24 |
BUS_NAME = 'org.freedesktop.CHANGEME' |
| 25 |
MAIN_OBJ = '/org/freedesktop/CHANGEME' |
| 26 |
# If your top-level object is an org.freedesktop.DBus.ObjectManager, you can |
| 27 |
# skip setting MAIN_IFACE and set IS_OBJECT_MANAGER to True; then dbusmock will |
| 28 |
# automatically provide the GetManagedObjects() API. In all other cases, |
| 29 |
# specify the interface name of the main object here. |
| 30 |
MAIN_IFACE = 'org.freedesktop.CHANGEME' |
| 31 |
# IS_OBJECT_MANAGER = True |
| 32 |
|
| 33 |
|
| 34 |
def load(mock, parameters): |
| 35 |
mock.AddMethods(MAIN_IFACE, [ |
| 36 |
# CHANGEME: Add some methods if required, otherwise drop the AddMethods call |
| 37 |
('CHANGEME', '', 'b', 'ret = %s' % parameters.get('CHANGEME', True)), |
| 38 |
]) |
| 39 |
|
| 40 |
mock.AddProperties(MAIN_IFACE, |
| 41 |
dbus.Dictionary({ |
| 42 |
# CHANGEME: Add properties if required, otherwise |
| 43 |
# drop this call |
| 44 |
'MyProperty': parameters.get('MyProperty', 'CHANGEME'), |
| 45 |
}, signature='sv')) |
| 46 |
|
| 47 |
|
| 48 |
# CHANGEME: You can add convenience methods to the org.freedesktop.DBus.Mock |
| 49 |
# interface to provide abstract functionality such as adding specific devices |
| 50 |
|
| 51 |
@dbus.service.method(MOCK_IFACE, |
| 52 |
in_signature='ss', out_signature='s') |
| 53 |
def AddCHANGEME(self, device_name, _CHANGEME): |
| 54 |
'''Convenience method to add a CHANGEME object |
| 55 |
|
| 56 |
You have to specify a ... |
| 57 |
|
| 58 |
Please note that this does not set any global properties. |
| 59 |
|
| 60 |
Returns the new object path. |
| 61 |
''' |
| 62 |
path = '/org/freedesktop/CHANGEME/' + device_name |
| 63 |
self.AddObject(path, ...) |
| 64 |
return path |