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
65
66
67
|
"""
Test getting multiple room-list channels. telepathy-idle internally only
creates a single roomlist channel (since there's not really any reason to have
more than one) and passes that channel out whenever somebody asks for it.
This test just excercises the case where we've already created the channel and
we just need to hand it out to the next requestor
"""
from idletest import exec_test
from servicetest import EventPattern, call_async, assertEquals
import constants as cs
def test(q, bus, conn, stream):
conn.Connect()
q.expect_many(
EventPattern('dbus-signal', signal='StatusChanged', args=[1, 1]),
EventPattern('irc-connected'))
q.expect('dbus-signal', signal='SelfHandleChanged',
args=[1])
# request a roomlist channel
call_async(q, conn, 'CreateChannel',
{ cs.CHANNEL_TYPE: cs.CHANNEL_TYPE_ROOM_LIST },
dbus_interface=cs.CONN_IFACE_REQUESTS)
ret = q.expect('dbus-return', method='CreateChannel')
path, properties = ret.value
assertEquals(cs.CHANNEL_TYPE_ROOM_LIST, properties[cs.CHANNEL_TYPE])
# verify that a new channel was created and signalled
def looks_like_a_room_list(event):
channels, = event.args
if len(channels) != 1:
return False
path, props = channels[0]
return props[cs.CHANNEL_TYPE] == cs.CHANNEL_TYPE_ROOM_LIST and \
props[cs.TARGET_HANDLE_TYPE] == cs.HT_NONE and \
props[cs.TARGET_ID] == ''
e = q.expect('dbus-signal', signal='NewChannels',
predicate=looks_like_a_room_list)
# FIXME: this is pretty questionable.
# try to request another roomlist channel
call_async(q, conn, 'EnsureChannel',
{ cs.CHANNEL_TYPE: cs.CHANNEL_TYPE_ROOM_LIST },
dbus_interface=cs.CONN_IFACE_REQUESTS)
ret = q.expect('dbus-return', method='EnsureChannel')
yours, path2, properties2 = ret.value
# assert that it returns the same channel
assertEquals(path, path2)
assert not yours
call_async(q, conn, 'Disconnect')
q.expect_many(
EventPattern('dbus-return', method='Disconnect'),
EventPattern('dbus-signal', signal='ChannelClosed', args=[path]),
EventPattern('dbus-signal', signal='StatusChanged', args=[2, 1]))
return True
if __name__ == '__main__':
exec_test(test)
|