summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/twisted/test-debug.py22
-rw-r--r--tests/twisted/test-handle-normalisation.py4
-rw-r--r--tests/twisted/test-message.py31
-rw-r--r--tests/twisted/test-self-alias.py16
-rw-r--r--tests/twisted/text/initiate-requestotron.py18
-rw-r--r--tests/twisted/voip/calltest.py5
6 files changed, 50 insertions, 46 deletions
diff --git a/tests/twisted/test-debug.py b/tests/twisted/test-debug.py
index 090e80d..c8bec2c 100644
--- a/tests/twisted/test-debug.py
+++ b/tests/twisted/test-debug.py
@@ -5,7 +5,7 @@ Test the debug message interface.
import dbus
-from servicetest import assertEquals, sync_dbus
+from servicetest import assertEquals, sync_dbus, call_async
from sofiatest import exec_test
import constants as cs
from config import DEBUGGING
@@ -32,9 +32,14 @@ def test(q, bus, conn, stream):
assert props_iface.Get(cs.DEBUG_IFACE, 'Enabled') == False
props_iface.Set(cs.DEBUG_IFACE, 'Enabled', True)
- channel_path = conn.RequestChannel(
- cs.CHANNEL_TYPE_TEXT, cs.HT_CONTACT, conn.GetSelfHandle(), True)
- q.expect('dbus-signal', signal='NewChannel')
+ self_handle = conn.Get(cs.CONN, 'SelfHandle', dbus_interface=cs.PROPERTIES_IFACE)
+
+ channel_path, _ = conn.Requests.CreateChannel(
+ { cs.CHANNEL_TYPE: cs.CHANNEL_TYPE_TEXT,
+ cs.TARGET_HANDLE_TYPE: cs.HT_CONTACT,
+ cs.TARGET_HANDLE: self_handle })
+
+ q.expect('dbus-signal', signal='NewChannels')
if DEBUGGING:
assert len(messages) > 0
@@ -51,9 +56,12 @@ def test(q, bus, conn, stream):
channel.Close(dbus_interface=cs.CHANNEL)
q.expect('dbus-signal', signal='Closed')
- conn.RequestChannel(
- cs.CHANNEL_TYPE_TEXT, cs.HT_CONTACT, conn.GetSelfHandle(), True)
- q.expect('dbus-signal', signal='NewChannel')
+ channel_path, _ = conn.Requests.CreateChannel(
+ { cs.CHANNEL_TYPE: cs.CHANNEL_TYPE_TEXT,
+ cs.TARGET_HANDLE_TYPE: cs.HT_CONTACT,
+ cs.TARGET_HANDLE: self_handle })
+
+ q.expect('dbus-signal', signal='NewChannels')
assertEquals (snapshot, messages)
diff --git a/tests/twisted/test-handle-normalisation.py b/tests/twisted/test-handle-normalisation.py
index 710ed72..19cfdce 100644
--- a/tests/twisted/test-handle-normalisation.py
+++ b/tests/twisted/test-handle-normalisation.py
@@ -31,8 +31,8 @@ def test(q, bus, conn, sip):
orig = [ x[0] for x in tests ]
expect = [ x[1] for x in tests ]
- handles = conn.RequestHandles(1, orig)
- names = conn.InspectHandles(1, handles)
+ handles = conn.get_contact_handles_sync(orig)
+ names = conn.inspect_contacts_sync(handles)
for a,b in zip(expect, names):
assertEquals(a, b)
diff --git a/tests/twisted/test-message.py b/tests/twisted/test-message.py
index a3ecae1..cca8f66 100644
--- a/tests/twisted/test-message.py
+++ b/tests/twisted/test-message.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-from servicetest import (unwrap, assertSameSets)
+from servicetest import (unwrap, assertSameSets, assertEquals)
from sofiatest import exec_test
import constants as cs
@@ -16,12 +16,14 @@ import uuid
FROM_URL = 'sip:other.user@somewhere.else.com'
def test_new_channel(q, bus, conn, target_uri, initiator_uri, requested):
- event = q.expect('dbus-signal', signal='NewChannel')
- assert (event.args[1] == cs.CHANNEL_TYPE_TEXT and event.args[2] == 1)
- handle = event.args[3]
- obj = bus.get_object(conn._named_service, event.args[0])
+ event = q.expect('dbus-signal', signal='NewChannels')
+ path, props = event.args[0][0]
+ assertEquals(cs.CHANNEL_TYPE_TEXT, props[cs.CHANNEL_TYPE])
+ assertEquals(cs.HT_CONTACT, props[cs.TARGET_HANDLE_TYPE])
+ handle = props[cs.TARGET_HANDLE]
+ obj = bus.get_object(conn._named_service, path)
- initiator_handle = conn.RequestHandles(1, [initiator_uri])[0]
+ initiator_handle = conn.get_contact_handle_sync(initiator_uri)
text_props = obj.GetAll(cs.CHANNEL,
dbus_interface='org.freedesktop.DBus.Properties')
@@ -42,21 +44,22 @@ def test_new_channel(q, bus, conn, target_uri, initiator_uri, requested):
assert 'Requested' in text_props, text_props
assert text_props['Requested'] == requested, text_props
- if initiator_handle != handle:
- conn.ReleaseHandles(1, [initiator_handle])
-
return obj, handle
def test(q, bus, conn, sip):
conn.Connect()
q.expect('dbus-signal', signal='StatusChanged', args=[0, 1])
- self_handle = conn.GetSelfHandle()
- self_uri = conn.InspectHandles(1, [self_handle])[0]
+ self_handle = conn.Get(cs.CONN, 'SelfHandle', dbus_interface=cs.PROPERTIES_IFACE)
+ self_uri = conn.inspect_contact_sync(self_handle)
contact = 'sip:user@somewhere.com'
- handle = conn.RequestHandles(1, [contact])[0]
- chan = conn.RequestChannel(cs.CHANNEL_TYPE_TEXT, 1, handle, True)
+ handle = conn.get_contact_handle_sync(contact)
+
+ chan, _ = conn.Requests.CreateChannel(
+ { cs.CHANNEL_TYPE: cs.CHANNEL_TYPE_TEXT,
+ cs.TARGET_HANDLE_TYPE: cs.HT_CONTACT,
+ cs.TARGET_HANDLE: handle })
requested_obj, target_handle = test_new_channel (q, bus, conn,
target_uri=contact,
@@ -95,7 +98,7 @@ def test(q, bus, conn, sip):
iface = dbus.Interface(incoming_obj, cs.CHANNEL_TYPE_TEXT)
- name = conn.InspectHandles(1, [handle])[0]
+ name = conn.inspect_contact_sync(handle)
assert name == FROM_URL
event = q.expect('dbus-signal', signal='MessageReceived')
diff --git a/tests/twisted/test-self-alias.py b/tests/twisted/test-self-alias.py
index 8e6e585..908d256 100644
--- a/tests/twisted/test-self-alias.py
+++ b/tests/twisted/test-self-alias.py
@@ -11,7 +11,7 @@ def test(q, bus, conn, sip_proxy):
conn.Connect()
q.expect('dbus-signal', signal='StatusChanged', args=[0, 1])
- self_handle = conn.GetSelfHandle()
+ self_handle = conn.Get(cs.CONN, 'SelfHandle', dbus_interface=cs.PROPERTIES_IFACE)
default_alias = conn.Aliasing.GetAliases([self_handle])[self_handle]
@@ -20,7 +20,7 @@ def test(q, bus, conn, sip_proxy):
event = q.expect('dbus-signal', signal='AliasesChanged',
args=[[(self_handle, u'foo@bar.baz')]])
- handle = conn.RequestHandles(1, ['sip:user@somewhere.com'])[0]
+ handle = conn.get_contact_handle_sync('sip:user@somewhere.com')
assert cs.CONN_IFACE_ALIASING in \
conn.Properties.Get(cs.CONN_IFACE_CONTACTS, "ContactAttributeInterfaces")
@@ -29,17 +29,21 @@ def test(q, bus, conn, sip_proxy):
assert cs.CONN_IFACE_ALIASING + "/alias" in attrs[self_handle]
assert attrs[self_handle][cs.CONN_IFACE_ALIASING + "/alias"] == u'foo@bar.baz'
- conn.RequestChannel(cs.CHANNEL_TYPE_TEXT, 1, handle, True)
+ conn.Requests.CreateChannel(
+ { cs.CHANNEL_TYPE: cs.CHANNEL_TYPE_TEXT,
+ cs.TARGET_HANDLE_TYPE: cs.HT_CONTACT,
+ cs.TARGET_HANDLE: handle })
- event = q.expect('dbus-signal', signal='NewChannel')
+ event = q.expect('dbus-signal', signal='NewChannels')
+ path, props = event.args[0][0]
- text_iface = dbus.Interface(bus.get_object(conn.bus_name, event.args[0]),
+ text_iface = dbus.Interface(bus.get_object(conn.bus_name, path),
cs.CHANNEL_TYPE_TEXT)
text_iface.Send(0, 'Check the display name in From')
event = q.expect('sip-message')
- self_uri = conn.InspectHandles(1, [self_handle])[0]
+ self_uri = conn.inspect_contact_sync(self_handle)
from_header = event.sip_message.headers['from'][0]
assert from_header.startswith('"foo@bar.baz" <' + self_uri + '>'), from_header
diff --git a/tests/twisted/text/initiate-requestotron.py b/tests/twisted/text/initiate-requestotron.py
index ac94460..e1fd66a 100644
--- a/tests/twisted/text/initiate-requestotron.py
+++ b/tests/twisted/text/initiate-requestotron.py
@@ -12,14 +12,11 @@ def test(q, bus, conn, stream):
conn.Connect()
q.expect('dbus-signal', signal='StatusChanged', args=[0, 1])
- self_handle = conn.GetSelfHandle()
- self_uri = conn.InspectHandles(1, [self_handle])[0]
+ self_handle = conn.Get(cs.CONN, 'SelfHandle', dbus_interface=cs.PROPERTIES_IFACE)
+ self_uri = conn.inspect_contact_sync(self_handle)
uri = 'sip:foo@bar.com'
- call_async(q, conn, 'RequestHandles', 1, [uri])
-
- event = q.expect('dbus-return', method='RequestHandles')
- foo_handle = event.value[0][0]
+ foo_handle = conn.get_contact_handle_sync(uri)
properties = conn.GetAll(cs.CONN_IFACE_REQUESTS,
dbus_interface=cs.PROPERTIES_IFACE)
@@ -36,9 +33,8 @@ def test(q, bus, conn, stream):
cs.TARGET_HANDLE_TYPE: cs.HT_CONTACT,
cs.TARGET_HANDLE: foo_handle })
- ret, old_sig, new_sig = q.expect_many(
+ ret, new_sig = q.expect_many(
EventPattern('dbus-return', method='CreateChannel'),
- EventPattern('dbus-signal', signal='NewChannel'),
EventPattern('dbus-signal', signal='NewChannels'),
)
@@ -52,12 +48,6 @@ def test(q, bus, conn, stream):
assertEquals(self_handle, emitted_props[cs.INITIATOR_HANDLE])
assertEquals(self_uri, emitted_props[cs.INITIATOR_ID])
- assert old_sig.args[0] == ret.value[0]
- assert old_sig.args[1] == cs.CHANNEL_TYPE_TEXT
- assert old_sig.args[2] == cs.HT_CONTACT
- assert old_sig.args[3] == foo_handle
- assert old_sig.args[4] == True # suppress handler
-
assert len(new_sig.args) == 1
assert len(new_sig.args[0]) == 1 # one channel
assert len(new_sig.args[0][0]) == 2 # two struct members
diff --git a/tests/twisted/voip/calltest.py b/tests/twisted/voip/calltest.py
index 1cc3cc9..d9da66f 100644
--- a/tests/twisted/voip/calltest.py
+++ b/tests/twisted/voip/calltest.py
@@ -59,9 +59,8 @@ class CallTest:
self.context = VoipTestContext(self.q, self.conn, self.bus,
self.sip_proxy,
'sip:testacc@127.0.0.1', self.peer)
- self.self_handle = self.conn.GetSelfHandle()
- self.remote_handle = self.conn.RequestHandles(1,
- [self.context.peer])[0]
+ self.self_handle = self.conn.Get(cs.CONN, 'SelfHandle', dbus_interface=cs.PROPERTIES_IFACE)
+ self.remote_handle = self.conn.get_contact_handle_sync(self.context.peer)
def check_channel_props(self, props, initial):
assertEquals(cs.CHANNEL_TYPE_CALL, props[cs.CHANNEL_TYPE])