[Telepathy-commits] [telepathy-gabble/master] Use set_up_echo from tubetestutil
Will Thompson
will.thompson at collabora.co.uk
Tue Feb 3 11:48:04 PST 2009
One version lowercased all text, one uppercased all text, and two did
nothing. I chose to use the lowercasing version everywhere.
---
tests/twisted/tubes/ensure-si-tube.py | 20 +++-------------
.../offer-accept-private-dbus-stream-tube-ibb.py | 20 +---------------
...offer-accept-private-dbus-stream-tube-socks5.py | 19 +--------------
...offer-accept-private-stream-tube-si-fallback.py | 24 ++++---------------
4 files changed, 13 insertions(+), 70 deletions(-)
diff --git a/tests/twisted/tubes/ensure-si-tube.py b/tests/twisted/tubes/ensure-si-tube.py
index e84a0fb..4b1bf8c 100644
--- a/tests/twisted/tubes/ensure-si-tube.py
+++ b/tests/twisted/tubes/ensure-si-tube.py
@@ -18,6 +18,8 @@ from twisted.internet.protocol import Factory, Protocol
from twisted.internet import reactor
from twisted.words.protocols.jabber.client import IQ
+import tubetestutil as t
+
NS_TUBES = 'http://telepathy.freedesktop.org/xmpp/tubes'
NS_SI = 'http://jabber.org/protocol/si'
NS_FEATURE_NEG = 'http://jabber.org/protocol/feature-neg'
@@ -32,23 +34,9 @@ sample_parameters = dbus.Dictionary({
}, signature='sv')
-class Echo(Protocol):
- def dataReceived(self, data):
- self.transport.write(data)
-
-def set_up_echo():
- factory = Factory()
- factory.protocol = Echo
- try:
- os.remove(os.getcwd() + '/stream')
- except OSError, e:
- if e.errno != errno.ENOENT:
- raise
- reactor.listenUNIX(os.getcwd() + '/stream', factory)
-
-
def test(q, bus, conn, stream):
- set_up_echo()
+ t.set_up_echo('')
+
conn.Connect()
properties = conn.GetAll(
diff --git a/tests/twisted/tubes/offer-accept-private-dbus-stream-tube-ibb.py b/tests/twisted/tubes/offer-accept-private-dbus-stream-tube-ibb.py
index 962da0c..0a5b4c5 100644
--- a/tests/twisted/tubes/offer-accept-private-dbus-stream-tube-ibb.py
+++ b/tests/twisted/tubes/offer-accept-private-dbus-stream-tube-ibb.py
@@ -1,7 +1,6 @@
"""Test 1-1 tubes support."""
import base64
-import errno
import os
import dbus
@@ -16,7 +15,6 @@ import tubetestutil as t
from dbus import PROPERTIES_IFACE
from twisted.words.xish import domish, xpath
-from twisted.internet.protocol import Factory, Protocol
from twisted.internet import reactor
from twisted.words.protocols.jabber.client import IQ
@@ -41,20 +39,6 @@ new_sample_parameters = dbus.Dictionary({
'i': dbus.Int32(-123),
}, signature='sv')
-class Echo(Protocol):
- def dataReceived(self, data):
- self.transport.write(data)
-
-def set_up_echo(name):
- factory = Factory()
- factory.protocol = Echo
- try:
- os.remove(os.getcwd() + '/stream' + name)
- except OSError, e:
- if e.errno != errno.ENOENT:
- raise
- reactor.listenUNIX(os.getcwd() + '/stream' + name, factory)
-
def check_channel_properties(q, bus, conn, stream, channel, channel_type,
contact_handle, contact_id, state=None):
# Exercise basic Channel Properties from spec 0.17.7
@@ -151,8 +135,8 @@ def contact_offer_dbus_tube(stream, si_id, tube_id):
stream.send(iq)
def test(q, bus, conn, stream):
- set_up_echo("")
- set_up_echo("2")
+ t.set_up_echo("")
+ t.set_up_echo("2")
t.check_conn_properties(q, conn)
diff --git a/tests/twisted/tubes/offer-accept-private-dbus-stream-tube-socks5.py b/tests/twisted/tubes/offer-accept-private-dbus-stream-tube-socks5.py
index cf83b7c..d4ee59b 100644
--- a/tests/twisted/tubes/offer-accept-private-dbus-stream-tube-socks5.py
+++ b/tests/twisted/tubes/offer-accept-private-dbus-stream-tube-socks5.py
@@ -41,21 +41,6 @@ new_sample_parameters = dbus.Dictionary({
'i': dbus.Int32(-123),
}, signature='sv')
-
-class Echo(Protocol):
- def dataReceived(self, data):
- self.transport.write(data.lower())
-
-def set_up_echo(name):
- factory = Factory()
- factory.protocol = Echo
- try:
- os.remove(os.getcwd() + '/stream' + name)
- except OSError, e:
- if e.errno != errno.ENOENT:
- raise
- reactor.listenUNIX(os.getcwd() + '/stream' + name, factory)
-
class S5BProtocol(Protocol):
def connectionMade(self):
self.factory.event_func(EventPattern('s5b-connected',
@@ -194,8 +179,8 @@ def check_NewChannels_signal(new_sig, channel_type, chan_path, contact_handle,
def test(q, bus, conn, stream):
- set_up_echo("")
- set_up_echo("2")
+ t.set_up_echo("")
+ t.set_up_echo("2")
check_conn_properties(q, conn)
diff --git a/tests/twisted/tubes/offer-accept-private-stream-tube-si-fallback.py b/tests/twisted/tubes/offer-accept-private-stream-tube-si-fallback.py
index 885cfd2..dd78d6b 100644
--- a/tests/twisted/tubes/offer-accept-private-stream-tube-si-fallback.py
+++ b/tests/twisted/tubes/offer-accept-private-stream-tube-si-fallback.py
@@ -1,7 +1,6 @@
"""Test stream initiation fallback."""
import base64
-import errno
import os
import dbus
@@ -12,10 +11,11 @@ from servicetest import call_async, EventPattern, tp_name_prefix, watch_tube_sig
from gabbletest import exec_test, acknowledge_iq
from twisted.words.xish import domish, xpath
-from twisted.internet.protocol import Factory, Protocol
from twisted.internet import reactor
from twisted.words.protocols.jabber.client import IQ
+import tubetestutil as t
+
NS_TUBES = 'http://telepathy.freedesktop.org/xmpp/tubes'
NS_SI = 'http://jabber.org/protocol/si'
NS_FEATURE_NEG = 'http://jabber.org/protocol/feature-neg'
@@ -24,22 +24,8 @@ NS_X_DATA = 'jabber:x:data'
NS_BYTESTREAMS = 'http://jabber.org/protocol/bytestreams'
NS_SI_MULTIPLE = 'http://telepathy.freedesktop.org/xmpp/si-multiple'
-class Echo(Protocol):
- def dataReceived(self, data):
- self.transport.write(data.upper())
-
-def set_up_echo():
- factory = Factory()
- factory.protocol = Echo
- try:
- os.remove(os.getcwd() + '/stream')
- except OSError, e:
- if e.errno != errno.ENOENT:
- raise
- reactor.listenUNIX(os.getcwd() + '/stream', factory)
-
def test(q, bus, conn, stream):
- set_up_echo()
+ t.set_up_echo('')
conn.Connect()
@@ -215,7 +201,7 @@ def test(q, bus, conn, stream):
data_node = message.addElement((NS_IBB, 'data'))
data_node['sid'] = 'alpha'
data_node['seq'] = '0'
- data_node.addContent(base64.b64encode('hello, world'))
+ data_node.addContent(base64.b64encode('HELLO, WORLD'))
stream.send(message)
event = q.expect('stream-message', to='bob at localhost/Bob')
@@ -228,7 +214,7 @@ def test(q, bus, conn, stream):
ibb_data = data_nodes[0]
assert ibb_data['sid'] == 'alpha'
binary = base64.b64decode(str(ibb_data))
- assert binary == 'HELLO, WORLD'
+ assert binary == 'hello, world'
# Test the other side. Bob offers a stream tube.
--
1.5.6.5
More information about the telepathy-commits
mailing list