[Telepathy-commits] [telepathy-haze/master] Update hazetest, servicetest, constants and ns from Gabble master.

Will Thompson will.thompson at collabora.co.uk
Sun Mar 22 03:19:50 PDT 2009


---
 tests/twisted/constants.py   |   61 +++++++++++++++++++++++++++++++++++++++++-
 tests/twisted/hazetest.py    |   34 ++++++++++++++++++-----
 tests/twisted/ns.py          |   15 ++++++++++
 tests/twisted/servicetest.py |    2 +-
 4 files changed, 102 insertions(+), 10 deletions(-)

diff --git a/tests/twisted/constants.py b/tests/twisted/constants.py
index c39b0c4..ca2efec 100644
--- a/tests/twisted/constants.py
+++ b/tests/twisted/constants.py
@@ -2,13 +2,26 @@
 Some handy constants for other tests to share and enjoy.
 """
 
+from dbus import PROPERTIES_IFACE
+
 HT_CONTACT = 1
+HT_ROOM = 2
 
 CHANNEL = "org.freedesktop.Telepathy.Channel"
 CHANNEL_IFACE_GROUP = CHANNEL + ".Interface.Group"
+CHANNEL_IFACE_HOLD = CHANNEL + ".Interface.Hold"
+CHANNEL_IFACE_MEDIA_SIGNALLING = CHANNEL + ".Interface.MediaSignalling"
+CHANNEL_TYPE_TEXT = CHANNEL + ".Type.Text"
 CHANNEL_TYPE_TUBES = CHANNEL + ".Type.Tubes"
 CHANNEL_IFACE_TUBE = CHANNEL + ".Interface.Tube.DRAFT"
 CHANNEL_TYPE_STREAM_TUBE = CHANNEL + ".Type.StreamTube.DRAFT"
+CHANNEL_TYPE_DBUS_TUBE = CHANNEL + ".Type.DBusTube.DRAFT"
+CHANNEL_TYPE_STREAMED_MEDIA = CHANNEL + ".Type.StreamedMedia"
+CHANNEL_TYPE_TEXT = CHANNEL + ".Type.Text"
+
+TP_AWKWARD_PROPERTIES = "org.freedesktop.Telepathy.Properties"
+PROPERTY_FLAG_READ = 1
+PROPERTY_FLAG_WRITE = 2
 
 CHANNEL_TYPE = CHANNEL + '.ChannelType'
 TARGET_HANDLE_TYPE = CHANNEL + '.TargetHandleType'
@@ -17,8 +30,11 @@ TARGET_ID = CHANNEL + '.TargetID'
 REQUESTED = CHANNEL + '.Requested'
 INITIATOR_HANDLE = CHANNEL + '.InitiatorHandle'
 INITIATOR_ID = CHANNEL + '.InitiatorID'
+INTERFACES = CHANNEL + '.Interfaces'
 
 CONN = "org.freedesktop.Telepathy.Connection"
+CONN_IFACE_CONTACTS = CONN + '.Interface.Contacts'
+CONN_IFACE_CONTACT_CAPA = CONN + '.Interface.ContactCapabilities.DRAFT'
 CONN_IFACE_REQUESTS = CONN + '.Interface.Requests'
 
 ERRORS = 'org.freedesktop.Telepathy.Errors'
@@ -27,10 +43,53 @@ NOT_IMPLEMENTED = ERRORS + '.NotImplemented'
 NOT_AVAILABLE = ERRORS + '.NotAvailable'
 
 TUBE_PARAMETERS = CHANNEL_IFACE_TUBE + '.Parameters'
-TUBE_STATUS = CHANNEL_IFACE_TUBE + '.Status'
+TUBE_STATE = CHANNEL_IFACE_TUBE + '.State'
 STREAM_TUBE_SERVICE = CHANNEL_TYPE_STREAM_TUBE + '.Service'
+DBUS_TUBE_SERVICE_NAME = CHANNEL_TYPE_DBUS_TUBE + '.ServiceName'
+DBUS_TUBE_DBUS_NAMES = CHANNEL_TYPE_DBUS_TUBE + '.DBusNames'
 
 TUBE_CHANNEL_STATE_LOCAL_PENDING = 0
 TUBE_CHANNEL_STATE_REMOTE_PENDING = 1
 TUBE_CHANNEL_STATE_OPEN = 2
 TUBE_CHANNEL_STATE_NOT_OFFERED = 3
+
+MEDIA_STREAM_TYPE_AUDIO = 0
+MEDIA_STREAM_TYPE_VIDEO = 1
+
+SOCKET_ADDRESS_TYPE_UNIX = 0
+SOCKET_ADDRESS_TYPE_ABSTRACT_UNIX = 1
+SOCKET_ADDRESS_TYPE_IPV4 = 2
+SOCKET_ADDRESS_TYPE_IPV6 = 3
+
+SOCKET_ACCESS_CONTROL_LOCALHOST = 0
+SOCKET_ACCESS_CONTROL_PORT = 1
+SOCKET_ACCESS_CONTROL_NETMASK = 2
+SOCKET_ACCESS_CONTROL_CREDENTIALS = 3
+
+TUBE_STATE_LOCAL_PENDING = 0
+TUBE_STATE_REMOTE_PENDING = 1
+TUBE_STATE_OPEN = 2
+TUBE_STATE_NOT_OFFERED = 3
+
+TUBE_TYPE_DBUS = 0
+TUBE_TYPE_STREAM = 1
+
+MEDIA_STREAM_DIRECTION_NONE = 0
+MEDIA_STREAM_DIRECTION_SEND = 1
+MEDIA_STREAM_DIRECTION_RECEIVE = 2
+MEDIA_STREAM_DIRECTION_BIDIRECTIONAL = 3
+
+MEDIA_STREAM_PENDING_LOCAL_SEND = 1
+MEDIA_STREAM_PENDING_REMOTE_SEND = 2
+
+MEDIA_STREAM_TYPE_AUDIO = 0
+MEDIA_STREAM_TYPE_VIDEO = 1
+
+MEDIA_STREAM_STATE_DISCONNECTED = 0
+MEDIA_STREAM_STATE_CONNECTING = 1
+MEDIA_STREAM_STATE_CONNECTED = 2
+
+MEDIA_STREAM_DIRECTION_NONE = 0
+MEDIA_STREAM_DIRECTION_SEND = 1
+MEDIA_STREAM_DIRECTION_RECEIVE = 2
+MEDIA_STREAM_DIRECTION_BIDIRECTIONAL = 3
diff --git a/tests/twisted/hazetest.py b/tests/twisted/hazetest.py
index 25aaa03..d2960f8 100644
--- a/tests/twisted/hazetest.py
+++ b/tests/twisted/hazetest.py
@@ -5,10 +5,10 @@ Infrastructure code for testing Haze by pretending to be a Jabber server.
 
 import base64
 import os
-import random
 import sha
 import sys
 import time
+import random
 
 import ns
 import servicetest
@@ -57,22 +57,27 @@ def request_muc_handle(q, conn, stream, muc_jid):
     event = q.expect('dbus-return', method='RequestHandles')
     return event.value[0][0]
 
-def make_muc_presence(affiliation, role, muc_jid, alias):
+def make_muc_presence(affiliation, role, muc_jid, alias, jid=None):
     presence = domish.Element((None, 'presence'))
     presence['from'] = '%s/%s' % (muc_jid, alias)
     x = presence.addElement((ns.MUC_USER, 'x'))
     item = x.addElement('item')
     item['affiliation'] = affiliation
     item['role'] = role
+    if jid is not None:
+        item['jid'] = jid
     return presence
 
 def sync_stream(q, stream):
     """Used to ensure that the CM has processed all stanzas sent to it."""
 
     iq = IQ(stream, "get")
+    id = iq['id']
     iq.addElement(('http://jabber.org/protocol/disco#info', 'query'))
     stream.send(iq)
-    q.expect('stream-iq', query_ns='http://jabber.org/protocol/disco#info')
+    q.expect('stream-iq', query_ns='http://jabber.org/protocol/disco#info',
+        predicate=(lambda event:
+            event.stanza['id'] == id and event.iq_type == 'result'))
 
 class JabberAuthenticator(xmlstream.Authenticator):
     "Trivial XML stream authenticator that accepts one username/digest pair."
@@ -381,11 +386,6 @@ def exec_test_deferred (funs, params, protocol=None, timeout=None):
 
         conn.Disconnect()
 
-        if 'HAZE_TEST_REFDBG' in os.environ:
-            # we have to wait that the CM timeouts so the process is properly
-            # exited and refdbg can generates its report
-            time.sleep(5.5)
-
     except dbus.DBusException, e:
         pass
 
@@ -498,3 +498,21 @@ def elem_iq(server, type, **kw):
             iq[k] = v
 
     return iq
+
+def make_presence(_from, to='test at localhost', type=None, status=None, caps=None):
+    presence = domish.Element((None, 'presence'))
+    presence['from'] = _from
+    presence['to'] = to
+
+    if type is not None:
+        presence['type'] = type
+
+    if status is not None:
+        presence.addElement('status', content=status)
+
+    if caps is not None:
+        cel = presence.addElement(('http://jabber.org/protocol/caps', 'c'))
+        for key,value in caps.items():
+            cel[key] = value
+
+    return presence
diff --git a/tests/twisted/ns.py b/tests/twisted/ns.py
index e0d0aa0..143aa1c 100644
--- a/tests/twisted/ns.py
+++ b/tests/twisted/ns.py
@@ -1,7 +1,18 @@
 AMP = "http://jabber.org/protocol/amp"
+BYTESTREAMS = 'http://jabber.org/protocol/bytestreams'
+CHAT_STATES = 'http://jabber.org/protocol/chatstates'
+CAPS = "http://jabber.org/protocol/caps"
 DISCO_INFO = "http://jabber.org/protocol/disco#info"
 DISCO_ITEMS = "http://jabber.org/protocol/disco#items"
+FEATURE_NEG = 'http://jabber.org/protocol/feature-neg'
+GOOGLE_JINGLE_INFO = 'google:jingleinfo'
+GOOGLE_P2P = "http://www.google.com/transport/p2p"
+GOOGLE_ROSTER = 'google:roster'
+IBB = 'http://jabber.org/protocol/ibb'
+JINGLE = "http://jabber.org/protocol/jingle"
+JINGLE_AUDIO = "http://jabber.org/protocol/jingle/description/audio"
 MUC = 'http://jabber.org/protocol/muc'
+MUC_BYTESTREAM = 'http://telepathy.freedesktop.org/xmpp/protocol/muc-bytestream'
 MUC_OWNER = '%s#owner' % MUC
 MUC_USER = '%s#user' % MUC
 OLPC_ACTIVITIES = "http://laptop.org/xmpp/activities"
@@ -15,4 +26,8 @@ OLPC_BUDDY_PROPS_NOTIFY = "%s+notify" % OLPC_BUDDY_PROPS
 OLPC_CURRENT_ACTIVITY = "http://laptop.org/xmpp/current-activity"
 OLPC_CURRENT_ACTIVITY_NOTIFY = "%s+notify" % OLPC_CURRENT_ACTIVITY
 PUBSUB = "http://jabber.org/protocol/pubsub"
+SI = 'http://jabber.org/protocol/si'
+SI_MULTIPLE = 'http://telepathy.freedesktop.org/xmpp/si-multiple'
 STANZA = "urn:ietf:params:xml:ns:xmpp-stanzas"
+TUBES = 'http://telepathy.freedesktop.org/xmpp/tubes'
+X_DATA = 'jabber:x:data'
diff --git a/tests/twisted/servicetest.py b/tests/twisted/servicetest.py
index e63235e..b8485e1 100644
--- a/tests/twisted/servicetest.py
+++ b/tests/twisted/servicetest.py
@@ -426,7 +426,7 @@ def make_connection(bus, event_func, name, proto, params):
         dict([
             (name, tp_name_prefix + '.Connection.Interface.' + name)
             for name in ['Aliasing', 'Avatars', 'Capabilities', 'Contacts',
-              'Presence']] +
+              'Presence', 'SimplePresence', 'Requests']] +
         [('Peer', 'org.freedesktop.DBus.Peer')]))
 
     bus.add_signal_receiver(
-- 
1.5.6.5




More information about the telepathy-commits mailing list