[telepathy-sofiasip/master] Test setting alias for the self handle

Mikhail Zabaluev mikhail.zabaluev at nokia.com
Fri Sep 25 10:38:03 PDT 2009


It's expected to produce a properly quoted display name in the From header
for outbound requests.
---
 tests/twisted/Makefile.am        |    1 +
 tests/twisted/test-self-alias.py |   40 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 41 insertions(+), 0 deletions(-)
 create mode 100644 tests/twisted/test-self-alias.py

diff --git a/tests/twisted/Makefile.am b/tests/twisted/Makefile.am
index 2e8b5b3..3b5e483 100644
--- a/tests/twisted/Makefile.am
+++ b/tests/twisted/Makefile.am
@@ -3,6 +3,7 @@ TWISTED_TESTS = \
 	test-register-fail.py \
 	test-handle-normalisation.py \
 	test-message.py \
+	test-self-alias.py \
 	text/initiate-requestotron.py
 
 TESTS =
diff --git a/tests/twisted/test-self-alias.py b/tests/twisted/test-self-alias.py
new file mode 100644
index 0000000..863d1e1
--- /dev/null
+++ b/tests/twisted/test-self-alias.py
@@ -0,0 +1,40 @@
+#
+# Test alias setting for the self handle
+#
+
+from sofiatest import exec_test
+from servicetest import tp_name_prefix
+
+import dbus
+
+TEXT_TYPE = tp_name_prefix + '.Channel.Type.Text'
+
+def test(q, bus, conn, sip_proxy):
+    conn.Connect()
+    q.expect('dbus-signal', signal='StatusChanged', args=[0, 1])
+
+    self_handle = conn.GetSelfHandle()
+
+    conn.Aliasing.SetAliases({self_handle: 'foo at bar.baz'})
+
+    event = q.expect('dbus-signal', signal='AliasesChanged',
+        args=[[(self_handle, u'foo at bar.baz')]])
+
+    handle = conn.RequestHandles(1, ['sip:user at somewhere.com'])[0]
+    conn.RequestChannel(TEXT_TYPE, 1, handle, True)
+
+    event = q.expect('dbus-signal', signal='NewChannel')
+
+    text_iface = dbus.Interface(bus.get_object(conn.bus_name, event.args[0]),
+                               TEXT_TYPE)
+    text_iface.Send(0, 'Hello')
+
+    event = q.expect('sip-message')
+
+    self_uri = conn.InspectHandles(1, [self_handle])[0]
+
+    from_header = event.sip_message.headers['from'][0]
+    assert from_header.startswith('"foo at bar.baz" <' + self_uri + '>'), from_header
+
+if __name__ == '__main__':
+    exec_test(test)
-- 
1.5.6.5




More information about the telepathy-commits mailing list