~ubuntu-branches/ubuntu/maverick/telepathy-idle/maverick

« back to all changes in this revision

Viewing changes to tests/twisted/messages/message-order.py

  • Committer: Bazaar Package Importer
  • Author(s): Sjoerd Simons
  • Date: 2009-05-29 12:24:09 UTC
  • mfrom: (1.1.8 upstream) (2.1.2 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090529122409-q2jhmp7771szusbg
Tags: 0.1.4-1
New Upstream Version

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
 
8
8
from idletest import exec_test
9
9
from servicetest import EventPattern, call_async
 
10
from constants import *
10
11
import dbus
11
12
 
12
13
def test(q, bus, conn, stream):
13
14
    conn.Connect()
14
15
    q.expect('dbus-signal', signal='StatusChanged', args=[0, 1])
15
16
    CHANNEL_NAME = '#idletest'
16
 
    room_handles = conn.RequestHandles(2, [CHANNEL_NAME])
17
 
    call_async(q, conn, 'RequestChannel', 'org.freedesktop.Telepathy.Channel.Type.Text', 2, room_handles[0], True)
 
17
    room_handles = conn.RequestHandles(HT_ROOM, [CHANNEL_NAME])
 
18
    call_async(q, conn, 'RequestChannel', CHANNEL_TYPE_TEXT, HT_ROOM,
 
19
            room_handles[0], True)
18
20
 
19
21
    ret = q.expect('dbus-return', method='RequestChannel')
20
22
    q.expect('dbus-signal', signal='MembersChanged')
21
23
    chan = bus.get_object(conn.bus_name, ret.value[0])
22
24
 
23
 
    text_chan = dbus.Interface(chan,
24
 
        u'org.freedesktop.Telepathy.Channel.Type.Text')
 
25
    text_chan = dbus.Interface(chan, CHANNEL_TYPE_TEXT)
25
26
 
26
27
    # send a whole bunch of messages in a row and make sure they get delivered
27
28
    # in the proper order
28
 
    for i in range(4):
 
29
    NUM_MESSAGES = 4
 
30
    for i in range(NUM_MESSAGES):
29
31
        call_async(q, text_chan, 'Send', 0, str(i))
30
32
 
31
 
    for i in range(4):
32
 
        q.expect('irc-privmsg', data={'message':str(i),'recipient':CHANNEL_NAME})
 
33
    for i in range(NUM_MESSAGES):
 
34
        message = q.expect('stream-PRIVMSG')
 
35
        assert message.data[0] == CHANNEL_NAME
 
36
        assert message.data[1].rstrip('\r\n') == str(i)
33
37
 
34
38
    call_async(q, conn, 'Disconnect')
35
39
    return True