summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2010-11-18 18:16:37 +0000
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2010-11-18 18:16:37 +0000
commit167d76996438e4e8e3eacf36577ec196354d592e (patch)
treed07ae1afac32fd00540a27b569158319eaeaa4e6
parentc847c6bfd4e3d963fd7da2c481fc3078606a4ffe (diff)
Add a simple test for Protocol objects
-rw-r--r--tests/twisted/Makefile.am1
-rw-r--r--tests/twisted/cm/protocol.py58
2 files changed, 59 insertions, 0 deletions
diff --git a/tests/twisted/Makefile.am b/tests/twisted/Makefile.am
index 3b5e483..bc49772 100644
--- a/tests/twisted/Makefile.am
+++ b/tests/twisted/Makefile.am
@@ -1,4 +1,5 @@
TWISTED_TESTS = \
+ cm/protocol.py \
test-register.py \
test-register-fail.py \
test-handle-normalisation.py \
diff --git a/tests/twisted/cm/protocol.py b/tests/twisted/cm/protocol.py
new file mode 100644
index 0000000..f0b0c40
--- /dev/null
+++ b/tests/twisted/cm/protocol.py
@@ -0,0 +1,58 @@
+"""
+Test tpsip's o.fd.T.Protocol implementation
+"""
+
+import dbus
+from servicetest import (unwrap, tp_path_prefix, assertEquals, assertContains,
+ call_async)
+from sofiatest import exec_test
+import constants as cs
+
+def test(q, bus, conn, sip):
+ cm = bus.get_object(cs.CM + '.sofiasip',
+ tp_path_prefix + '/ConnectionManager/sofiasip')
+ cm_iface = dbus.Interface(cm, cs.CM)
+ cm_prop_iface = dbus.Interface(cm, cs.PROPERTIES_IFACE)
+
+ protocols = unwrap(cm_prop_iface.Get(cs.CM, 'Protocols'))
+ assertEquals(set(['sip']), set(protocols.keys()))
+
+ protocol_names = unwrap(cm_iface.ListProtocols())
+ assertEquals(set(['sip']), set(protocol_names))
+
+ cm_params = cm_iface.GetParameters('sip')
+ local_props = protocols['sip']
+ local_params = local_props[cs.PROTOCOL + '.Parameters']
+ assertEquals(cm_params, local_params)
+
+ proto = bus.get_object(cm.bus_name, cm.object_path + '/sip')
+ proto_iface = dbus.Interface(proto, cs.PROTOCOL)
+ proto_prop_iface = dbus.Interface(proto, cs.PROPERTIES_IFACE)
+ proto_props = unwrap(proto_prop_iface.GetAll(cs.PROTOCOL))
+
+ for key in ['Parameters', 'Interfaces', 'ConnectionInterfaces',
+ 'RequestableChannelClasses', u'VCardField', u'EnglishName', u'Icon']:
+ a = local_props[cs.PROTOCOL + '.' + key]
+ b = proto_props[key]
+ assertEquals(a, b)
+
+ assertEquals('x-sip', proto_props['VCardField'])
+ assertEquals('SIP', proto_props['EnglishName'])
+ assertEquals('im-sip', proto_props['Icon'])
+
+ assertContains(cs.CONN_IFACE_ALIASING, proto_props['ConnectionInterfaces'])
+ assertContains(cs.CONN_IFACE_CONTACTS, proto_props['ConnectionInterfaces'])
+ assertContains(cs.CONN_IFACE_REQUESTS, proto_props['ConnectionInterfaces'])
+
+ assertEquals('sip:example@mit.edu',
+ unwrap(proto_iface.NormalizeContact('example@MIT.Edu')))
+
+ # Only account is mandatory
+ call_async(q, proto_iface, 'IdentifyAccount', {})
+ q.expect('dbus-error', method='IdentifyAccount', name=cs.INVALID_ARGUMENT)
+ test_params = {'account': 'smcv@example.com'}
+ acc_name = unwrap(proto_iface.IdentifyAccount(test_params))
+ assertEquals('smcv@example.com', acc_name)
+
+if __name__ == '__main__':
+ exec_test(test)