[Telepathy-commits] [telepathy-idle/master] Clean up some connections in invalid-nick test
Jonathon Jongsma
jonathon.jongsma at collabora.co.uk
Fri Feb 13 21:52:16 PST 2009
Also assert that the dbus exception is the correct one. Changes per wjt's
review.
---
tests/twisted/connect/invalid-nick.py | 39 +++++++++++++++-----------------
1 files changed, 18 insertions(+), 21 deletions(-)
diff --git a/tests/twisted/connect/invalid-nick.py b/tests/twisted/connect/invalid-nick.py
index e547b62..6221632 100644
--- a/tests/twisted/connect/invalid-nick.py
+++ b/tests/twisted/connect/invalid-nick.py
@@ -4,8 +4,9 @@ Test that we get an error when attempting to use an invalid nick
"""
import dbus
+from idletest import make_connection
-def make_connection(nick):
+def connect(nick):
bus = dbus.SessionBus()
params = {
'account': nick,
@@ -18,49 +19,45 @@ def make_connection(nick):
'port': dbus.UInt32(6900),
}
- cm = bus.get_object(
- 'org.freedesktop.Telepathy.ConnectionManager.idle',
- '/org/freedesktop/Telepathy/ConnectionManager/idle')
- cm_iface = dbus.Interface(cm, 'org.freedesktop.Telepathy.ConnectionManager')
-
- connection_name, connection_path = cm_iface.RequestConnection(
- 'irc', params)
+ conn = make_connection(bus, None, params)
+ conn.Connect(reply_handler=None, error_handler=None)
+ conn.Disconnect(reply_handler=None, error_handler=None)
def test():
try:
- make_connection('nick with spaces')
+ connect('nick with spaces')
raise RuntimeError('Invalid nick not rejected')
except dbus.DBusException, e:
- pass # nick rejected properly with an error
+ assert e.get_dbus_name() == 'org.freedesktop.Telepathy.Errors.InvalidHandle'
try:
- make_connection('') # empty nick
+ connect('') # empty nick
raise RuntimeError('Invalid nick not rejected')
except dbus.DBusException, e:
- pass # nick rejected properly with an error
+ assert e.get_dbus_name() == 'org.freedesktop.Telepathy.Errors.InvalidHandle'
try:
- make_connection('#foo') # invalid chars
+ connect('#foo') # invalid chars
raise RuntimeError('Invalid nick not rejected')
except dbus.DBusException, e:
- pass # nick rejected properly with an error
+ assert e.get_dbus_name() == 'org.freedesktop.Telepathy.Errors.InvalidHandle'
try:
- make_connection(u'ê¹ì ì') # unicode
+ connect(u'ê¹ì ì') # unicode
raise RuntimeError('Invalid nick not rejected')
except dbus.DBusException, e:
- pass # nick rejected properly with an error
+ assert e.get_dbus_name() == 'org.freedesktop.Telepathy.Errors.InvalidHandle'
try:
- make_connection('-foo') # '-' not allowed as first char
+ connect('-foo') # '-' not allowed as first char
raise RuntimeError('Invalid nick not rejected')
except dbus.DBusException, e:
- pass # nick rejected properly with an error
+ assert e.get_dbus_name() == 'org.freedesktop.Telepathy.Errors.InvalidHandle'
# should pass succeed without an exception
- make_connection('good_nick')
- make_connection('good-nick')
- make_connection('{goodnick]`')
+ connect('good_nick')
+ connect('good-nick')
+ connect('{goodnick]`')
if __name__ == '__main__':
test()
--
1.5.6.5
More information about the telepathy-commits
mailing list