[Telepathy-commits] [telepathy-idle/master] Rework join-muc-channel.py test to not depend on object path

Jonathon Jongsma jonathon.jongsma at collabora.co.uk
Tue Feb 17 09:19:44 PST 2009


Yes, this is much much cleaner.  Also cleaned it up a lot by using constants
from constants.py
---
 tests/twisted/channels/join-muc-channel.py |   34 +++++++++++++++++----------
 tests/twisted/constants.py                 |    2 +
 2 files changed, 23 insertions(+), 13 deletions(-)

diff --git a/tests/twisted/channels/join-muc-channel.py b/tests/twisted/channels/join-muc-channel.py
index 01f0bc5..0643bac 100644
--- a/tests/twisted/channels/join-muc-channel.py
+++ b/tests/twisted/channels/join-muc-channel.py
@@ -5,7 +5,7 @@ Test connecting to a IRC channel
 
 from idletest import exec_test
 from servicetest import EventPattern, call_async
-import constants
+from constants import *
 import dbus
 
 def test(q, bus, conn, stream):
@@ -16,18 +16,26 @@ def test(q, bus, conn, stream):
     q.expect('dbus-signal', signal='SelfHandleChanged',
         args=[1L])
     q.expect('dbus-signal', signal='StatusChanged', args=[0, 1])
-    room_handles = conn.RequestHandles(2, ['#idletest'])
-    call_async(q, conn, 'RequestChannel', 'org.freedesktop.Telepathy.Channel.Type.Text', 2, room_handles[0], True)
-    q.expect('dbus-return', method='RequestChannel',
-            value=('/org/freedesktop/Telepathy/Connection/idle/irc/test_40localhost/MucChannel%d' % room_handles[0],))
-    q.expect('dbus-signal', signal='NewChannels',
-            args=[[('/org/freedesktop/Telepathy/Connection/idle/irc/test_40localhost/MucChannel%d' % room_handles[0],
-                { CHANNEL_TYPE: u'org.freedesktop.Telepathy.Channel.Type.Text',
-                    TARGET_HANDLE: room_handles[0],
-                    TARGET_HANDLE_TYPE: 2L})]])
-    q.expect('dbus-signal', signal='NewChannel',
-            args=['/org/freedesktop/Telepathy/Connection/idle/irc/test_40localhost/MucChannel%d' % room_handles[0],
-                u'org.freedesktop.Telepathy.Channel.Type.Text', 2L, room_handles[0], 1])
+    room_handles = conn.RequestHandles(HT_ROOM, ['#idletest'])
+    call_async(q, conn, 'RequestChannel', CHANNEL_TYPE_TEXT, HT_ROOM, room_handles[0], True)
+    event = q.expect('dbus-return', method='RequestChannel')
+    obj_path = event.value[0]
+
+    event = q.expect('dbus-signal', signal='NewChannels')
+    channel_details = event.args[0]
+    assert len(channel_details) == 1
+    path, props = channel_details[0]
+    assert path == obj_path
+    assert props[TARGET_HANDLE_TYPE] == HT_ROOM
+    assert props[TARGET_HANDLE] == room_handles[0]
+    assert props[CHANNEL_TYPE] == CHANNEL_TYPE_TEXT
+
+    event = q.expect('dbus-signal', signal='NewChannel')
+    assert event.args[0] == obj_path
+    assert event.args[1] == CHANNEL_TYPE_TEXT
+    assert event.args[2] == HT_ROOM
+    assert event.args[3] == room_handles[0]
+
     q.expect('dbus-signal', signal='MembersChanged')
     call_async(q, conn, 'Disconnect')
     q.expect_many(
diff --git a/tests/twisted/constants.py b/tests/twisted/constants.py
index 769bd9d..c3f4325 100644
--- a/tests/twisted/constants.py
+++ b/tests/twisted/constants.py
@@ -3,8 +3,10 @@ Some handy constants for other tests to share and enjoy.
 """
 
 HT_CONTACT = 1
+HT_ROOM = 2
 
 CHANNEL = "org.freedesktop.Telepathy.Channel"
+CHANNEL_TYPE_TEXT = CHANNEL + ".Type.Text"
 CHANNEL_IFACE_GROUP = CHANNEL + ".Interface.Group"
 CHANNEL_TYPE_TUBES = CHANNEL + ".Type.Tubes"
 CHANNEL_IFACE_TUBE = CHANNEL + ".Interface.Tube.DRAFT"
-- 
1.5.6.5




More information about the telepathy-commits mailing list