1'''notification-daemon mock template 2 3This creates the expected methods and properties of the notification-daemon 4services, but no devices. You can specify non-default capabilities in 5"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__ = 'Martin Pitt' 15__copyright__ = '(c) 2012 Canonical Ltd.' 16 17BUS_NAME = 'org.freedesktop.Notifications' 18MAIN_OBJ = '/org/freedesktop/Notifications' 19MAIN_IFACE = 'org.freedesktop.Notifications' 20SYSTEM_BUS = False 21 22# default capabilities, can be modified with "capabilities" parameter 23default_caps = ['body', 'body-markup', 'icon-static', 'image/svg+xml', 24 'private-synchronous', 'append', 'private-icon-only', 25 'truncation'] 26 27 28def load(mock, parameters): 29 if 'capabilities' in parameters: 30 caps = parameters['capabilities'].split() 31 else: 32 caps = default_caps 33 34 # next notification ID 35 mock.next_id = 1 36 37 mock.AddMethods(MAIN_IFACE, [ 38 ('GetCapabilities', '', 'as', f'ret = {repr(caps)}'), 39 ('CloseNotification', 'i', '', 'if args[0] < self.next_id: self.EmitSignal(' 40 '"", "NotificationClosed", "uu", [args[0], 1])'), 41 ('GetServerInformation', '', 'ssss', 'ret = ("mock-notify", "test vendor", "1.0", "1.1")'), 42 ('Notify', 'susssasa{sv}i', 'u', '''if args[1]: 43 ret = args[1] 44else: 45 ret = self.next_id 46 self.next_id += 1 47'''), 48 ]) 49