File: SKELETON

package info (click to toggle)
python-dbusmock 0.36.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 812 kB
  • sloc: python: 7,324; sh: 73; makefile: 4
file content (64 lines) | stat: -rw-r--r-- 2,350 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
'''CHANGEME mock template

This creates the expected methods and properties of the main
CHANGEME object, but no devices. You can specify any property
such as CHANGEME in "parameters".
'''

# 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__ = 'CHANGEME'
__copyright__ = 'CHANGEME'

import dbus

from dbusmock import MOCK_IFACE

# False for session bus, True for system bus; if not present, the bus has to be
# specified in the spawn_server_template() call
SYSTEM_BUS = True  # CHANGEME
BUS_NAME = 'org.freedesktop.CHANGEME'
MAIN_OBJ = '/org/freedesktop/CHANGEME'
# If your top-level object is an org.freedesktop.DBus.ObjectManager, you can
# skip setting MAIN_IFACE and set IS_OBJECT_MANAGER to True; then dbusmock will
# automatically provide the GetManagedObjects() API. In all other cases,
# specify the interface name of the main object here.
MAIN_IFACE = 'org.freedesktop.CHANGEME'
# IS_OBJECT_MANAGER = True


def load(mock, parameters):
    mock.AddMethods(MAIN_IFACE, [
        # CHANGEME: Add some methods if required, otherwise drop the AddMethods call
        ('CHANGEME', '', 'b', 'ret = %s' % parameters.get('CHANGEME', True)),
    ])

    mock.AddProperties(MAIN_IFACE,
                       dbus.Dictionary({
                           # CHANGEME: Add properties if required, otherwise
                           # drop this call
                           'MyProperty': parameters.get('MyProperty', 'CHANGEME'),
                       }, signature='sv'))


# CHANGEME: You can add convenience methods to the org.freedesktop.DBus.Mock
# interface to provide abstract functionality such as adding specific devices

@dbus.service.method(MOCK_IFACE,
                     in_signature='ss', out_signature='s')
def AddCHANGEME(self, device_name, _CHANGEME):
    '''Convenience method to add a CHANGEME object

    You have to specify a ...

    Please note that this does not set any global properties.

    Returns the new object path.
    '''
    path = '/org/freedesktop/CHANGEME/' + device_name
    self.AddObject(path, ...)
    return path