[Telepathy-commits] [telepathy-gabble/master] Rename new tests to what they test, rather than the bug they demonstrated
Will Thompson
will.thompson at collabora.co.uk
Mon Sep 22 10:05:34 PDT 2008
---
tests/twisted/Makefile.am | 4 +-
tests/twisted/roster/request-group-after-roster.py | 59 ++++++++++++++++++++
.../twisted/roster/request-group-before-roster.py | 53 ++++++++++++++++++
tests/twisted/roster/request-never-answered-2.py | 59 --------------------
tests/twisted/roster/request-never-answered.py | 53 ------------------
5 files changed, 114 insertions(+), 114 deletions(-)
create mode 100644 tests/twisted/roster/request-group-after-roster.py
create mode 100644 tests/twisted/roster/request-group-before-roster.py
delete mode 100644 tests/twisted/roster/request-never-answered-2.py
delete mode 100644 tests/twisted/roster/request-never-answered.py
diff --git a/tests/twisted/Makefile.am b/tests/twisted/Makefile.am
index 5a5a2c6..1c327ac 100644
--- a/tests/twisted/Makefile.am
+++ b/tests/twisted/Makefile.am
@@ -12,8 +12,8 @@ TWISTED_TESTS = \
presence/presence.py \
roster/groups.py \
roster/groups-12791.py \
- roster/request-never-answered.py \
- roster/request-never-answered-2.py \
+ roster/request-group-before-roster.py \
+ roster/request-group-after-roster.py \
roster/test-google-roster.py \
roster/test-roster.py \
roster/test-roster-subscribe.py \
diff --git a/tests/twisted/roster/request-group-after-roster.py b/tests/twisted/roster/request-group-after-roster.py
new file mode 100644
index 0000000..9e33274
--- /dev/null
+++ b/tests/twisted/roster/request-group-after-roster.py
@@ -0,0 +1,59 @@
+"""
+Exhibit a bug where CreateChannel times out when requesting a group channel
+after the roster has been received.
+"""
+
+import dbus
+
+from gabbletest import exec_test, sync_stream
+from servicetest import sync_dbus, call_async
+
+HT_CONTACT_LIST = 3
+HT_GROUP = 4
+
+def test(q, bus, conn, stream):
+ conn.Connect()
+ # q.expect('dbus-signal', signal='StatusChanged', args=[0, 1])
+
+ roster_event = q.expect('stream-iq', query_ns='jabber:iq:roster')
+ roster_event.stanza['type'] = 'result'
+
+ call_async(q, conn, "RequestHandles", HT_GROUP, ['test'])
+
+ event = q.expect('dbus-return', method='RequestHandles')
+ test_handle = event.value[0][0]
+
+ # send an empty roster
+ stream.send(roster_event.stanza)
+
+ sync_stream(q, stream)
+ sync_dbus(bus, q, conn)
+
+ requestotron = dbus.Interface(conn,
+ 'org.freedesktop.Telepathy.Connection.Interface.Requests')
+ call_async(q, requestotron, 'CreateChannel',
+ { 'org.freedesktop.Telepathy.Channel.ChannelType':
+ 'org.freedesktop.Telepathy.Channel.Type.ContactList',
+ 'org.freedesktop.Telepathy.Channel.TargetHandleType': HT_GROUP,
+ 'org.freedesktop.Telepathy.Channel.TargetHandle': test_handle,
+ })
+
+ event = q.expect('dbus-signal', signal='NewChannels')
+ path, props = event.args[0][0]
+ assert props['org.freedesktop.Telepathy.Channel.ChannelType'] ==\
+ 'org.freedesktop.Telepathy.Channel.Type.ContactList', props
+ assert props['org.freedesktop.Telepathy.Channel.TargetHandleType'] ==\
+ HT_GROUP, props
+ assert props['org.freedesktop.Telepathy.Channel.TargetHandle'] ==\
+ test_handle, props
+ assert props['org.freedesktop.Telepathy.Channel.TargetID'] ==\
+ 'test', props
+
+ event = q.expect('dbus-return', method='CreateChannel')
+ ret_path, ret_props = event.value
+
+ assert ret_path == path, (ret_path, path)
+ assert ret_props == props, (ret_props, props)
+
+if __name__ == '__main__':
+ exec_test(test)
diff --git a/tests/twisted/roster/request-group-before-roster.py b/tests/twisted/roster/request-group-before-roster.py
new file mode 100644
index 0000000..deb3776
--- /dev/null
+++ b/tests/twisted/roster/request-group-before-roster.py
@@ -0,0 +1,53 @@
+"""
+Exhibit a bug where RequestChannel times out when requesting a group channel
+if the roster hasn't been received at the time of the call.
+"""
+
+import dbus
+
+from gabbletest import exec_test, sync_stream
+from servicetest import sync_dbus, call_async
+
+HT_GROUP = 4
+
+def test(q, bus, conn, stream):
+ conn.Connect()
+ # q.expect('dbus-signal', signal='StatusChanged', args=[0, 1])
+
+ roster_event = q.expect('stream-iq', query_ns='jabber:iq:roster')
+ roster_event.stanza['type'] = 'result'
+
+ call_async(q, conn, "RequestHandles", HT_GROUP, ['test'])
+
+ event = q.expect('dbus-return', method='RequestHandles')
+ test_handle = event.value[0][0]
+
+ call_async(q, conn, 'RequestChannel',
+ 'org.freedesktop.Telepathy.Channel.Type.ContactList', HT_GROUP,
+ test_handle, True)
+
+ # A previous incarnation of this test --- written with the intention that
+ # RequestChannel would be called before the roster was received, to expose
+ # a bug in Gabble triggered by that ordering --- was racy: if the D-Bus
+ # daemon happened to be particularly busy, the call to RequestChannel
+ # reached Gabble after the roster stanza. (The race was discovered when
+ # that reversed order triggered a newly-introduced instance of the
+ # opposite bug to the one the test was targetting!) So we sync the XMPP
+ # stream and D-Bus queue here.
+ sync_stream(q, stream)
+ sync_dbus(bus, q, conn)
+
+ # send an empty roster
+ stream.send(roster_event.stanza)
+
+ while True:
+ event = q.expect('dbus-signal', signal='NewChannel')
+ path, type, handle_type, handle, suppress_handler = event.args
+ if handle_type == HT_GROUP and handle == test_handle:
+ break;
+
+ event = q.expect('dbus-return', method='RequestChannel')
+ assert event.value[0] == path, (event.args[0], path)
+
+if __name__ == '__main__':
+ exec_test(test)
diff --git a/tests/twisted/roster/request-never-answered-2.py b/tests/twisted/roster/request-never-answered-2.py
deleted file mode 100644
index 9e33274..0000000
--- a/tests/twisted/roster/request-never-answered-2.py
+++ /dev/null
@@ -1,59 +0,0 @@
-"""
-Exhibit a bug where CreateChannel times out when requesting a group channel
-after the roster has been received.
-"""
-
-import dbus
-
-from gabbletest import exec_test, sync_stream
-from servicetest import sync_dbus, call_async
-
-HT_CONTACT_LIST = 3
-HT_GROUP = 4
-
-def test(q, bus, conn, stream):
- conn.Connect()
- # q.expect('dbus-signal', signal='StatusChanged', args=[0, 1])
-
- roster_event = q.expect('stream-iq', query_ns='jabber:iq:roster')
- roster_event.stanza['type'] = 'result'
-
- call_async(q, conn, "RequestHandles", HT_GROUP, ['test'])
-
- event = q.expect('dbus-return', method='RequestHandles')
- test_handle = event.value[0][0]
-
- # send an empty roster
- stream.send(roster_event.stanza)
-
- sync_stream(q, stream)
- sync_dbus(bus, q, conn)
-
- requestotron = dbus.Interface(conn,
- 'org.freedesktop.Telepathy.Connection.Interface.Requests')
- call_async(q, requestotron, 'CreateChannel',
- { 'org.freedesktop.Telepathy.Channel.ChannelType':
- 'org.freedesktop.Telepathy.Channel.Type.ContactList',
- 'org.freedesktop.Telepathy.Channel.TargetHandleType': HT_GROUP,
- 'org.freedesktop.Telepathy.Channel.TargetHandle': test_handle,
- })
-
- event = q.expect('dbus-signal', signal='NewChannels')
- path, props = event.args[0][0]
- assert props['org.freedesktop.Telepathy.Channel.ChannelType'] ==\
- 'org.freedesktop.Telepathy.Channel.Type.ContactList', props
- assert props['org.freedesktop.Telepathy.Channel.TargetHandleType'] ==\
- HT_GROUP, props
- assert props['org.freedesktop.Telepathy.Channel.TargetHandle'] ==\
- test_handle, props
- assert props['org.freedesktop.Telepathy.Channel.TargetID'] ==\
- 'test', props
-
- event = q.expect('dbus-return', method='CreateChannel')
- ret_path, ret_props = event.value
-
- assert ret_path == path, (ret_path, path)
- assert ret_props == props, (ret_props, props)
-
-if __name__ == '__main__':
- exec_test(test)
diff --git a/tests/twisted/roster/request-never-answered.py b/tests/twisted/roster/request-never-answered.py
deleted file mode 100644
index deb3776..0000000
--- a/tests/twisted/roster/request-never-answered.py
+++ /dev/null
@@ -1,53 +0,0 @@
-"""
-Exhibit a bug where RequestChannel times out when requesting a group channel
-if the roster hasn't been received at the time of the call.
-"""
-
-import dbus
-
-from gabbletest import exec_test, sync_stream
-from servicetest import sync_dbus, call_async
-
-HT_GROUP = 4
-
-def test(q, bus, conn, stream):
- conn.Connect()
- # q.expect('dbus-signal', signal='StatusChanged', args=[0, 1])
-
- roster_event = q.expect('stream-iq', query_ns='jabber:iq:roster')
- roster_event.stanza['type'] = 'result'
-
- call_async(q, conn, "RequestHandles", HT_GROUP, ['test'])
-
- event = q.expect('dbus-return', method='RequestHandles')
- test_handle = event.value[0][0]
-
- call_async(q, conn, 'RequestChannel',
- 'org.freedesktop.Telepathy.Channel.Type.ContactList', HT_GROUP,
- test_handle, True)
-
- # A previous incarnation of this test --- written with the intention that
- # RequestChannel would be called before the roster was received, to expose
- # a bug in Gabble triggered by that ordering --- was racy: if the D-Bus
- # daemon happened to be particularly busy, the call to RequestChannel
- # reached Gabble after the roster stanza. (The race was discovered when
- # that reversed order triggered a newly-introduced instance of the
- # opposite bug to the one the test was targetting!) So we sync the XMPP
- # stream and D-Bus queue here.
- sync_stream(q, stream)
- sync_dbus(bus, q, conn)
-
- # send an empty roster
- stream.send(roster_event.stanza)
-
- while True:
- event = q.expect('dbus-signal', signal='NewChannel')
- path, type, handle_type, handle, suppress_handler = event.args
- if handle_type == HT_GROUP and handle == test_handle:
- break;
-
- event = q.expect('dbus-return', method='RequestChannel')
- assert event.value[0] == path, (event.args[0], path)
-
-if __name__ == '__main__':
- exec_test(test)
--
1.5.6.5
More information about the Telepathy-commits
mailing list