[telepathy-mission-control/master] mctest: un-stub the Channels property on connections; use SimulatedChannel in test-connect
Simon McVittie
simon.mcvittie at collabora.co.uk
Wed Apr 1 08:01:40 PDT 2009
---
test/twisted/mctest.py | 25 ++++++++++++++++++++++++-
test/twisted/test-connect.py | 12 +++++-------
2 files changed, 29 insertions(+), 8 deletions(-)
diff --git a/test/twisted/mctest.py b/test/twisted/mctest.py
index 80f07a9..d9e5a53 100644
--- a/test/twisted/mctest.py
+++ b/test/twisted/mctest.py
@@ -127,6 +127,7 @@ class SimulatedConnection(object):
self.reason = cs.CONN_STATUS_CONNECTING
self.self_ident = self_ident
self.self_handle = self.ensure_handle(cs.HT_CONTACT, self_ident)
+ self.channels = []
q.add_dbus_method_impl(self.Connect,
path=self.object_path, interface=cs.CONN, method='Connect')
@@ -178,10 +179,14 @@ class SimulatedConnection(object):
self.q.dbus_emit(self.object_path, cs.CONN, 'StatusChanged',
status, reason, signature='uu')
+ def get_channel_details(self):
+ return dbus.Array([(c.object_path, c.immutable)
+ for c in self.channels], signature='(oa{sv})')
+
def GetAll_Requests(self, e):
# FIXME: stub: assumes no channels
self.q.dbus_return(e.message, {
- 'Channels': dbus.Array(signature='(oa{sv})'),
+ 'Channels': self.get_channel_details(),
}, signature='a{sv}')
def GetSelfHandle(self, e):
@@ -205,6 +210,24 @@ class SimulatedChannel(object):
path=self.object_path,
interface=cs.PROPERTIES_IFACE, method='Get')
+ self.announced = False
+ self.closed = False
+
+ def announce(self):
+ assert not self.announced
+ self.conn.channels.append(self)
+ self.q.dbus_emit(self.conn.object_path, cs.CONN_IFACE_REQUESTS,
+ 'NewChannels', [(self.object_path, self.immutable)],
+ signature='a(oa{sv})')
+
+ def close(self):
+ assert self.announced
+ assert not self.closed
+ self.conn.channels.remove(self)
+ self.q.dbus_emit(self.object_path, cs.CHANNEL, 'Closed', signature='')
+ self.q.dbus_emit(conn.object_path, cs.CONN_IFACE_REQUESTS,
+ 'ChannelClosed', self.object_path, signature='o')
+
def GetAll(self, e):
iface = e.args[0] + '.'
diff --git a/test/twisted/test-connect.py b/test/twisted/test-connect.py
index 67de520..dceaf32 100644
--- a/test/twisted/test-connect.py
+++ b/test/twisted/test-connect.py
@@ -2,7 +2,8 @@ import dbus
import dbus.service
from servicetest import EventPattern, tp_name_prefix, tp_path_prefix
-from mctest import exec_test, SimulatedConnection, create_fakecm_account
+from mctest import exec_test, SimulatedConnection, create_fakecm_account,\
+ SimulatedChannel
import constants as cs
def test(q, bus, mc):
@@ -137,13 +138,10 @@ def test(q, bus, mc):
buddy_handle = conn.ensure_handle(cs.HT_CONTACT, "buddy")
new_channel[cs.CHANNEL + '.TargetID'] = "buddy"
new_channel[cs.CHANNEL + '.TargetHandle'] = buddy_handle
+ new_channel[cs.CHANNEL + '.Requested'] = False
- channel_path = dbus.ObjectPath(conn.object_path + '/channel')
- q.dbus_emit(conn.object_path, cs.CONN_IFACE_REQUESTS, 'NewChannels',
- [(channel_path, new_channel)], signature='a(oa{sv})')
- q.dbus_emit(conn.object_path, cs.CONN, 'NewChannel',
- channel_path, cs.CHANNEL_TYPE_STREAM_TUBE,
- cs.HT_CONTACT, buddy_handle, False, signature='osuub')
+ chan = SimulatedChannel(conn, new_channel)
+ chan.announce()
e = q.expect('dbus-method-call', method='HandleChannels')
--
1.5.6.5
More information about the telepathy-commits
mailing list