1# vim: set fileencoding=utf-8 : 2# 3# Copyright © 2011-2012 Collabora Ltd. 4# 5# This library is free software; you can redistribute it and/or 6# modify it under the terms of the GNU Lesser General Public 7# License as published by the Free Software Foundation; either 8# version 2.1 of the License, or (at your option) any later version. 9# 10# This library is distributed in the hope that it will be useful, but 11# WITHOUT ANY WARRANTY; without even the implied warranty of 12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13# Lesser General Public License for more details. 14# 15# You should have received a copy of the GNU Lesser General Public 16# License along with this library; if not, write to the Free Software 17# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 18# 02110-1301 USA 19 20import dbus 21from servicetest import ( 22 tp_name_prefix, tp_path_prefix, assertEquals, 23) 24from mctest import ( 25 exec_test, create_fakecm_account, SimulatedConnection, 26) 27import constants as cs 28 29def test(q, bus, mc): 30 params = dbus.Dictionary( 31 {"account": "someguy@example.com", 32 "password": "secrecy", 33 }, signature='sv') 34 (cm_name_ref, account) = create_fakecm_account(q, bus, mc, params) 35 36 account.Properties.Set(cs.ACCOUNT, 'Enabled', True) 37 38 # Set online presence 39 presence = dbus.Struct( 40 (dbus.UInt32(cs.PRESENCE_TYPE_BUSY), 'busy', 'Fixing MC bugs'), 41 signature='uss') 42 account.Properties.Set(cs.ACCOUNT, 'RequestedPresence', presence) 43 44 e = q.expect('dbus-method-call', method='RequestConnection', 45 args=['fakeprotocol', params], 46 destination=tp_name_prefix + '.ConnectionManager.fakecm', 47 path=tp_path_prefix + '/ConnectionManager/fakecm', 48 interface=tp_name_prefix + '.ConnectionManager', 49 handled=False) 50 51 q.dbus_raise(e.message, cs.NOT_IMPLEMENTED, "CM is broken") 52 53 # MC should report the connection dying. 54 e = q.expect('dbus-signal', signal='AccountPropertyChanged', 55 predicate=lambda e: 'ConnectionError' in e.args[0]) 56 changed, = e.args 57 assertEquals('/', changed['Connection']) 58 assertEquals(cs.CONN_STATUS_DISCONNECTED, changed['ConnectionStatus']) 59 assertEquals(cs.CONN_STATUS_REASON_NONE, changed['ConnectionStatusReason']) 60 assertEquals(cs.NOT_IMPLEMENTED, changed['ConnectionError']) 61 62if __name__ == '__main__': 63 exec_test(test) 64