summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2011-03-17 10:51:31 +0100
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2011-03-17 10:51:31 +0100
commita0973b79e828e48097b3de3b39b480292ba20be3 (patch)
treeea2126a8685418531fcddd176b9f99058845e6f2 /tests
parentbf1d7bf5a6e0d5227619ad4639e73553b235177f (diff)
message-iface: check content of received messages
Diffstat (limited to 'tests')
-rw-r--r--tests/twisted/messages/messages-iface.py23
1 files changed, 19 insertions, 4 deletions
diff --git a/tests/twisted/messages/messages-iface.py b/tests/twisted/messages/messages-iface.py
index 7406067..c6a5353 100644
--- a/tests/twisted/messages/messages-iface.py
+++ b/tests/twisted/messages/messages-iface.py
@@ -3,7 +3,7 @@ Test Messages interface implementation
"""
from idletest import exec_test
-from servicetest import EventPattern, call_async, assertContains
+from servicetest import EventPattern, call_async, assertContains, assertEquals
import constants as cs
import dbus
@@ -42,6 +42,16 @@ def test_dbus_properties (chan):
# Don't check props['DeliveryReportingSupport'] as tp-glib uses to forget
# this property
+def check_message(conn, msg):
+ header = msg[0]
+ assertEquals('alice', header['message-sender-id'])
+ handle = header['message-sender']
+ assertEquals('alice', conn.InspectHandles(cs.HT_CONTACT, [handle])[0])
+
+ body = msg[1]
+ assertEquals(body['content'], 'pony!')
+ assertEquals(body['content-type'], 'text/plain')
+
def test(q, bus, conn, stream):
conn.Connect()
q.expect('dbus-signal', signal='StatusChanged',
@@ -65,11 +75,13 @@ def test(q, bus, conn, stream):
# Receive a message on the channel
stream.sendMessage('PRIVMSG', '#test', ":pony!", prefix='alice')
- q.expect_many(
+ _, e = q.expect_many(
EventPattern('dbus-signal', interface=cs.CHANNEL_TYPE_TEXT, signal='Received'),
EventPattern('dbus-signal', interface=cs.CHANNEL_IFACE_MESSAGES,
signal='MessageReceived'))
+ check_message(conn, e.args[0])
+
test_dbus_properties(chan)
# test private channel
@@ -87,12 +99,15 @@ def test(q, bus, conn, stream):
test_sending(q, bus, conn, stream, chan)
# Receive a private message from Alice
- stream.sendMessage('PRIVMSG', stream.nick, ":badger!", prefix='alice')
- q.expect_many(
+ stream.sendMessage('PRIVMSG', stream.nick, ":pony!", prefix='alice')
+
+ _, e = q.expect_many(
EventPattern('dbus-signal', interface=cs.CHANNEL_TYPE_TEXT, signal='Received'),
EventPattern('dbus-signal', interface=cs.CHANNEL_IFACE_MESSAGES,
signal='MessageReceived'))
+ check_message(conn, e.args[0])
+
test_dbus_properties(chan)
# we're done