summaryrefslogtreecommitdiff
path: root/tests/twisted/channels/muc-destroy.py
blob: 3513098302f59c2a55c52c1c1208cd8148bbab65 (plain)
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
"""
Tests Destroy()ing a MUC.
"""

from servicetest import call_async, wrap_channel, EventPattern
from idletest import exec_test
import constants as cs

def test(q, bus, conn, stream):
    conn.Connect()
    q.expect('dbus-signal', signal='StatusChanged',
        args=[cs.CONN_STATUS_CONNECTED, cs.CSR_REQUESTED])

    call_async(q, conn.Requests, "CreateChannel", {
        cs.CHANNEL_TYPE: cs.CHANNEL_TYPE_TEXT,
        cs.ROOM_NAME: "#everythingyoutouch",
    })
    q.expect('stream-JOIN')
    event = q.expect('dbus-return', method='CreateChannel')
    path, props = event.value
    chan = wrap_channel(bus.get_object(conn.bus_name, path), 'Text',
        ['Destroyable'])

    call_async(q, chan.Destroyable, "Destroy")
    q.expect_many(
        EventPattern('stream-PART'),
        EventPattern('dbus-signal', signal='Closed', path=path),
        EventPattern('dbus-return', method='Destroy'),
    )

if __name__ == '__main__':
    exec_test(test)