~ubuntu-branches/ubuntu/precise/telepathy-mission-control-5/precise

« back to all changes in this revision

Viewing changes to test/twisted/account-manager/create-auto-connect.py

  • Committer: Bazaar Package Importer
  • Author(s): Simon McVittie
  • Date: 2009-07-30 12:11:55 UTC
  • mto: (0.4.1 upstream) (7.1.1 lucid) (1.1.6 upstream)
  • mto: This revision was merged to the branch mainline in revision 6.
  • Revision ID: james.westby@ubuntu.com-20090730121155-6745f645s3fg1mpk
ImportĀ upstreamĀ versionĀ 5.2.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (C) 2009 Nokia Corporation
 
2
# Copyright (C) 2009 Collabora Ltd.
 
3
#
 
4
# This library is free software; you can redistribute it and/or
 
5
# modify it under the terms of the GNU Lesser General Public
 
6
# License as published by the Free Software Foundation; either
 
7
# version 2.1 of the License, or (at your option) any later version.
 
8
#
 
9
# This library is distributed in the hope that it will be useful, but
 
10
# WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 
12
# Lesser General Public License for more details.
 
13
#
 
14
# You should have received a copy of the GNU Lesser General Public
 
15
# License along with this library; if not, write to the Free Software
 
16
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 
17
# 02110-1301 USA
 
18
 
 
19
import dbus
 
20
import dbus
 
21
import dbus.service
 
22
 
 
23
from servicetest import EventPattern, tp_name_prefix, tp_path_prefix, \
 
24
        call_async
 
25
from mctest import exec_test, create_fakecm_account
 
26
import constants as cs
 
27
 
 
28
def test(q, bus, mc):
 
29
    account_manager = bus.get_object(cs.AM, cs.AM_PATH)
 
30
    account_manager_iface = dbus.Interface(account_manager, cs.AM)
 
31
 
 
32
    params = dbus.Dictionary({"account": "smcv@example.com",
 
33
        "password": "secrecy"}, signature='sv')
 
34
    (cm_name_ref, account) = create_fakecm_account(q, bus, mc, params)
 
35
 
 
36
    account_iface = dbus.Interface(account, cs.ACCOUNT)
 
37
    account_props = dbus.Interface(account, cs.PROPERTIES_IFACE)
 
38
 
 
39
    # Ensure that it's enabled but has offline RP
 
40
 
 
41
    call_async(q, account_props, 'Set', cs.ACCOUNT, 'RequestedPresence',
 
42
            (dbus.UInt32(cs.PRESENCE_TYPE_OFFLINE), 'offline', ''))
 
43
    q.expect('dbus-return', method='Set')
 
44
 
 
45
    call_async(q, account_props, 'Set', cs.ACCOUNT, 'AutomaticPresence',
 
46
            (dbus.UInt32(cs.PRESENCE_TYPE_BUSY), 'busy',
 
47
                'Testing automatic presence'))
 
48
    q.expect('dbus-return', method='Set')
 
49
    q.expect('dbus-signal', signal='AccountPropertyChanged',
 
50
            predicate=lambda e:
 
51
                e.args[0].get('AutomaticPresence', (None, None, None))[1]
 
52
                    == 'busy')
 
53
 
 
54
    call_async(q, account_props, 'Set', cs.ACCOUNT, 'Enabled', True)
 
55
    q.expect('dbus-return', method='Set')
 
56
    q.expect('dbus-signal', signal='AccountPropertyChanged',
 
57
            predicate=lambda e: e.args[0].get('Enabled'))
 
58
 
 
59
    # Go online by telling it to connect automatically
 
60
    call_async(q, account_props, 'Set', cs.ACCOUNT, 'ConnectAutomatically',
 
61
            True)
 
62
 
 
63
    e = q.expect('dbus-method-call', method='RequestConnection',
 
64
            args=['fakeprotocol', params],
 
65
            destination=cs.tp_name_prefix + '.ConnectionManager.fakecm',
 
66
            path=cs.tp_path_prefix + '/ConnectionManager/fakecm',
 
67
            interface=cs.tp_name_prefix + '.ConnectionManager',
 
68
            handled=False)
 
69
 
 
70
if __name__ == '__main__':
 
71
    exec_test(test, {})