diff options
author | Xavier Claessens <xavier.claessens@collabora.co.uk> | 2013-09-20 15:08:16 -0400 |
---|---|---|
committer | Xavier Claessens <xavier.claessens@collabora.co.uk> | 2013-09-24 14:45:10 -0400 |
commit | c63c10234fe0d60e2194204aadddde0ef1aedc58 (patch) | |
tree | 196f68d2f74a4efc06fa62778b0f5f53b75300c5 | |
parent | 13057873b29b66d03cabbcafb35b2aaa256a15c9 (diff) |
Tests: Stop using deprecated spec methods
21 files changed, 81 insertions, 317 deletions
diff --git a/tests/twisted/avahi/aliases.py b/tests/twisted/avahi/aliases.py index 02887803..41c82857 100644 --- a/tests/twisted/avahi/aliases.py +++ b/tests/twisted/avahi/aliases.py @@ -61,9 +61,6 @@ def check_all_contact_info_methods(conn, handle, keys): info = attrs[cs.CONN_IFACE_CONTACT_INFO + "/info"] check_contact_info(info, keys) - info = conn.ContactInfo.GetContactInfo([handle])[handle] - check_contact_info(info, keys) - info = conn.ContactInfo.RequestContactInfo(handle) check_contact_info(info, keys) @@ -152,17 +149,14 @@ def test(q, bus, conn): check_all_contact_info_methods(conn, handle, keys) - # Try an invalid handle. Both Get and Request should return InvalidHandle. + # Try an invalid handle. Request should return InvalidHandle. # (Technically so should RefreshContactInfo but I am lazy.) - call_async(q, conn.ContactInfo, 'GetContactInfo', [42]) - q.expect('dbus-error', method='GetContactInfo', name=cs.INVALID_HANDLE) call_async(q, conn.ContactInfo, 'RequestContactInfo', 42) q.expect('dbus-error', method='RequestContactInfo', name=cs.INVALID_HANDLE) - # Try a valid handle for whom we have no data from the network. Get should - # just omit them; Request should fail. - h = conn.RequestHandles(cs.HT_CONTACT, ['rthrtha@octopus'])[0] - assertEquals({}, conn.ContactInfo.GetContactInfo([h])) + # Try a valid handle for whom we have no data from the network. + # Request should fail. + h = conn.Contacts.GetContactByID('rthrtha@octopus', [])[0] call_async(q, conn.ContactInfo, 'RequestContactInfo', h) q.expect('dbus-error', method='RequestContactInfo', name=cs.NOT_AVAILABLE) diff --git a/tests/twisted/avahi/caps-file-transfer.py b/tests/twisted/avahi/caps-file-transfer.py index 627d43cb..c239fdfd 100644 --- a/tests/twisted/avahi/caps-file-transfer.py +++ b/tests/twisted/avahi/caps-file-transfer.py @@ -5,9 +5,8 @@ Test tubes capabilities with Connection.Interface.ContactCapabilities.DRAFT 1. Check if Salut advertise the OOB caps 2. Receive presence and caps from contacts and check that -GetContactCapabilities works correctly and that ContactCapabilitiesChanged is -correctly received. Also check that GetContactAttributes gives the same -results. +GetContactAttributes works correctly and that ContactCapabilitiesChanged is +correctly received. - capa announced with FT - capa announced without FT @@ -122,7 +121,7 @@ def test_ft_caps_from_contact(q, bus, conn, client): assert query_node.attributes['node'] == \ client + '#' + ver, (query_node.attributes['node'], client, ver) - contact_handle = conn.RequestHandles(cs.HT_CONTACT, [contact_name])[0] + contact_handle = conn_contacts_iface.GetContactByID(contact_name, [])[0] # send good reply result = make_result_iq(event.stanza) @@ -139,9 +138,6 @@ def test_ft_caps_from_contact(q, bus, conn, client): caps = e.args[0][contact_handle] assertContains(ft_caps, caps) - caps_get = conn_caps_iface.GetContactCapabilities([contact_handle])[contact_handle] - assert caps == caps_get - # check the Contacts interface give the same caps caps_via_contacts_iface = conn_contacts_iface.GetContactAttributes( [contact_handle], [cs.CONN_IFACE_CONTACT_CAPS], False) \ @@ -149,8 +145,8 @@ def test_ft_caps_from_contact(q, bus, conn, client): assert caps_via_contacts_iface == caps, caps_via_contacts_iface # check if Salut announces the OOB capa - self_handle = conn.GetSelfHandle() - self_handle_name = conn.InspectHandles(cs.HT_CONTACT, [self_handle])[0] + self_handle = conn.Properties.Get(cs.CONN, "SelfHandle") + self_handle_name = conn.Properties.Get(cs.CONN, "SelfID") AvahiListener(q).listen_for_service("_presence._tcp") e = q.expect('service-added', name = self_handle_name, @@ -180,7 +176,7 @@ def test_ft_caps_from_contact(q, bus, conn, client): assert query_node.attributes['node'] == \ client + '#' + ver, (query_node.attributes['node'], client, ver) - contact_handle = conn.RequestHandles(cs.HT_CONTACT, [contact_name])[0] + contact_handle = conn_contacts_iface.GetContactByID(contact_name, [])[0] # send good reply result = make_result_iq(event.stanza) @@ -196,14 +192,16 @@ def test_ft_caps_from_contact(q, bus, conn, client): caps = e.args[0][contact_handle] assertDoesNotContain(ft_caps, caps) - caps_get = conn_caps_iface.GetContactCapabilities([contact_handle])[contact_handle] - assert caps == caps_get - + # check the Contacts interface give the same caps + caps_via_contacts_iface = conn_contacts_iface.GetContactAttributes( + [contact_handle], [cs.CONN_IFACE_CONTACT_CAPS], False) \ + [contact_handle][cs.CONN_IFACE_CONTACT_CAPS + '/capabilities'] + assert caps_via_contacts_iface == caps, caps_via_contacts_iface # no capabilites announced (assume FT is supported to insure interop) txt_record = { "txtvers": "1", "status": "avail"} contact_name = "test-caps-ft-no-capa2@" + get_host_name() - contact_handle = conn.RequestHandles(cs.HT_CONTACT, [contact_name])[0] + contact_handle = conn_contacts_iface.GetContactByID(contact_name, [])[0] listener, port = setup_stream_listener(q, contact_name) announcer = AvahiAnnouncer(contact_name, "_presence._tcp", port, txt_record) @@ -215,8 +213,11 @@ def test_ft_caps_from_contact(q, bus, conn, client): caps = e.args[0][contact_handle] assertContains(ft_caps, caps) - caps_get = conn_caps_iface.GetContactCapabilities([contact_handle])[contact_handle] - assert caps == caps_get + # check the Contacts interface give the same caps + caps_via_contacts_iface = conn_contacts_iface.GetContactAttributes( + [contact_handle], [cs.CONN_IFACE_CONTACT_CAPS], False) \ + [contact_handle][cs.CONN_IFACE_CONTACT_CAPS + '/capabilities'] + assert caps_via_contacts_iface == caps, caps_via_contacts_iface def test(q, bus, conn): # last value of the "ver" key we resolved. We use it to be sure that the @@ -227,9 +228,11 @@ def test(q, bus, conn): q.expect('dbus-signal', signal='StatusChanged', args=[0, 0]) # check our own capabilities - self_handle = conn.GetSelfHandle() - conn_caps_iface = dbus.Interface(conn, cs.CONN_IFACE_CONTACT_CAPS) - caps = conn_caps_iface.GetContactCapabilities([self_handle])[self_handle] + self_handle = conn.Properties.Get(cs.CONN, "SelfHandle") + conn_contacts_iface = dbus.Interface(conn, cs.CONN_IFACE_CONTACTS) + caps = conn_contacts_iface.GetContactAttributes( + [self_handle], [cs.CONN_IFACE_CONTACT_CAPS], False) \ + [self_handle][cs.CONN_IFACE_CONTACT_CAPS + '/capabilities'] assertContains(ft_metadata_caps, caps) client = 'http://telepathy.freedesktop.org/fake-client' diff --git a/tests/twisted/avahi/caps-self.py b/tests/twisted/avahi/caps-self.py index e73c1fa3..4438d937 100644 --- a/tests/twisted/avahi/caps-self.py +++ b/tests/twisted/avahi/caps-self.py @@ -32,8 +32,8 @@ def test(q, bus, conn): conn.Connect() q.expect('dbus-signal', signal='StatusChanged', args=[0L, 0L]) - self_handle = conn.GetSelfHandle() - self_handle_name = conn.InspectHandles(HT_CONTACT, [self_handle])[0] + self_handle = conn.Properties.Get(cs.CONN, "SelfHandle") + self_handle_name = conn.Properties.Get(cs.CONN, "SelfID") AvahiListener(q).listen_for_service("_presence._tcp") e = q.expect('service-added', name = self_handle_name, diff --git a/tests/twisted/avahi/close-local-pending-room.py b/tests/twisted/avahi/close-local-pending-room.py index b6b2e081..1e04fa37 100644 --- a/tests/twisted/avahi/close-local-pending-room.py +++ b/tests/twisted/avahi/close-local-pending-room.py @@ -18,8 +18,8 @@ def test(q, bus, conn): q.expect('dbus-signal', signal='StatusChanged', args=[0L, 0L]) basic_txt = { "txtvers": "1", "status": "avail" } - self_handle = conn.GetSelfHandle() - self_handle_name = conn.InspectHandles(cs.HT_CONTACT, [self_handle])[0] + self_handle = conn.Properties.Get(cs.CONN, "SelfHandle") + self_handle_name = conn.Properties.Get(cs.CONN, "SelfID") contact_name = "test-text-channel@" + get_host_name() listener, port = setup_stream_listener(q, contact_name) diff --git a/tests/twisted/avahi/file-transfer/file_transfer_helper.py b/tests/twisted/avahi/file-transfer/file_transfer_helper.py index fee320e4..cb10c6b8 100644 --- a/tests/twisted/avahi/file-transfer/file_transfer_helper.py +++ b/tests/twisted/avahi/file-transfer/file_transfer_helper.py @@ -78,8 +78,8 @@ class FileTransferTest(object): self.conn.Connect() self.q.expect('dbus-signal', signal='StatusChanged', args=[0L, 0L]) - self.self_handle = self.conn.GetSelfHandle() - self.self_handle_name = self.conn.InspectHandles(cs.HT_CONTACT, [self.self_handle])[0] + self.self_handle = self.conn.Properties.Get(cs.CONN, "SelfHandle") + self.self_handle_name = self.conn.Properties.Get(cs.CONN, "SelfID") def announce_contact(self, name=CONTACT_NAME, metadata=True): client = 'http://telepathy.freedesktop.org/fake-client' diff --git a/tests/twisted/avahi/file-transfer/ft-client-caps.py b/tests/twisted/avahi/file-transfer/ft-client-caps.py index 40598936..3cb6aca3 100644 --- a/tests/twisted/avahi/file-transfer/ft-client-caps.py +++ b/tests/twisted/avahi/file-transfer/ft-client-caps.py @@ -129,18 +129,11 @@ def receive_caps(q, bus, conn, service, contact, contact_handle, features, # Make sure Salut's got the caps sync_stream(q, stream) - caps = conn.ContactCapabilities.GetContactCapabilities([contact_handle]) - assertSameElements(expected_caps, caps[contact_handle]) - - # test again, to check GetContactCapabilities does not have side effect - caps = conn.ContactCapabilities.GetContactCapabilities([contact_handle]) - assertSameElements(expected_caps, caps[contact_handle]) - # check the Contacts interface give the same caps caps_via_contacts_iface = conn.Contacts.GetContactAttributes( [contact_handle], [cs.CONN_IFACE_CONTACT_CAPS], False) \ [contact_handle][cs.ATTR_CONTACT_CAPABILITIES] - assertSameElements(caps[contact_handle], caps_via_contacts_iface) + assertSameElements(expected_caps, caps_via_contacts_iface) # close the connection and expect a new one to be opened by Salut # the next time we need some discoing doing @@ -153,17 +146,19 @@ def receive_caps(q, bus, conn, service, contact, contact_handle, features, sync_dbus(bus, q, conn) def test_ft_caps_from_contact(q, bus, conn, service, contact): - contact_handle = conn.RequestHandles(cs.HT_CONTACT, [contact])[0] + contact_handle = conn.Contacts.GetContactByID(contact, [])[0] # Check that we don't crash if we haven't seen any caps/presence for this # contact yet. - caps = conn.ContactCapabilities.GetContactCapabilities([contact_handle]) + caps = conn.Contacts.GetContactAttributes( + [contact_handle], [cs.CONN_IFACE_CONTACT_CAPS], False) \ + [contact_handle] basic_caps = [(text_fixed_properties, text_allowed_properties)] # Since we don't know their caps, they should be omitted from the dict, # rather than present with no caps, but all contacts have text chat caps. - assertEquals([], caps[contact_handle]) + assert cs.ATTR_CONTACT_CAPABILITIES not in caps # send presence with no FT cap # We don't expect ContactCapabilitiesChanged to be emitted here: we always @@ -213,8 +208,8 @@ def advertise_caps(q, bus, conn, service, filters, expected_features, unexpected # make sure nothing from a previous update is still running sync_dbus(bus, q, conn) - self_handle = conn.GetSelfHandle() - self_handle_name = conn.InspectHandles(1, [self_handle])[0] + self_handle = conn.Properties.Get(cs.CONN, "SelfHandle") + self_handle_name = conn.Properties.Get(cs.CONN, "SelfID") ret_caps = conn.ContactCapabilities.UpdateCapabilities( [(cs.CLIENT + '.Foo', filters, [])]) @@ -246,15 +241,11 @@ def advertise_caps(q, bus, conn, service, filters, expected_features, unexpected for var in unexpected_features: assertDoesNotContain(var, namespaces) - # Check our own caps - caps = conn.ContactCapabilities.GetContactCapabilities([self_handle]) - assertSameElements(expected_caps, caps[self_handle]) - # check the Contacts interface give the same caps caps_via_contacts_iface = conn.Contacts.GetContactAttributes( [self_handle], [cs.CONN_IFACE_CONTACT_CAPS], False) \ [self_handle][cs.ATTR_CONTACT_CAPABILITIES] - assertSameElements(caps[self_handle], caps_via_contacts_iface) + assertSameElements(expected_caps, caps_via_contacts_iface) # close things... outbound.send('</stream:stream>') @@ -262,7 +253,7 @@ def advertise_caps(q, bus, conn, service, filters, expected_features, unexpected outbound.transport.loseConnection() def test_ft_caps_to_contact(q, bus, conn, service): - self_handle = conn.GetSelfHandle() + self_handle = conn.Properties.Get(cs.CONN, "SelfHandle") basic_caps = [ (text_fixed_properties, text_allowed_properties), @@ -284,14 +275,10 @@ def test_ft_caps_to_contact(q, bus, conn, service): # # Check our own caps # - caps = conn.ContactCapabilities.GetContactCapabilities([self_handle]) - assertEquals(basic_caps, caps[self_handle]) - - # check the Contacts interface give the same caps caps_via_contacts_iface = conn.Contacts.GetContactAttributes( [self_handle], [cs.CONN_IFACE_CONTACT_CAPS], False) \ [self_handle][cs.ATTR_CONTACT_CAPABILITIES] - assertEquals(caps[self_handle], caps_via_contacts_iface) + assertEquals(basic_caps, caps_via_contacts_iface) # # Advertise nothing @@ -300,15 +287,10 @@ def test_ft_caps_to_contact(q, bus, conn, service): [(cs.CLIENT + '.Foo', {}, [])]) # Check our own caps - caps = conn.ContactCapabilities.GetContactCapabilities([self_handle]) - assertLength(1, caps) - assertEquals(basic_caps, caps[self_handle]) - - # check the Contacts interface give the same caps caps_via_contacts_iface = conn.Contacts.GetContactAttributes( [self_handle], [cs.CONN_IFACE_CONTACT_CAPS], False) \ [self_handle][cs.ATTR_CONTACT_CAPABILITIES] - assertEquals(caps[self_handle], caps_via_contacts_iface) + assertEquals(basic_caps, caps_via_contacts_iface) sync_dbus(bus, q, conn) @@ -319,15 +301,10 @@ def test_ft_caps_to_contact(q, bus, conn, service): [(cs.CLIENT + '.Foo', [no_service_fixed_properties], [])]) # Check our own caps - caps = conn.ContactCapabilities.GetContactCapabilities([self_handle]) - assertLength(1, caps) - assertEquals(basic_caps, caps[self_handle]) - - # check the Contacts interface give the same caps caps_via_contacts_iface = conn.Contacts.GetContactAttributes( [self_handle], [cs.CONN_IFACE_CONTACT_CAPS], False) \ [self_handle][cs.ATTR_CONTACT_CAPABILITIES] - assertEquals(caps[self_handle], caps_via_contacts_iface) + assertEquals(basic_caps, caps_via_contacts_iface) sync_dbus(bus, q, conn) @@ -338,15 +315,10 @@ def test_ft_caps_to_contact(q, bus, conn, service): [(cs.CLIENT + '.Foo', [outgoing_daap_fixed_properties], [])]) # Check our own caps - caps = conn.ContactCapabilities.GetContactCapabilities([self_handle]) - assertLength(1, caps) - assertEquals(basic_caps, caps[self_handle]) - - # check the Contacts interface give the same caps caps_via_contacts_iface = conn.Contacts.GetContactAttributes( [self_handle], [cs.CONN_IFACE_CONTACT_CAPS], False) \ [self_handle][cs.ATTR_CONTACT_CAPABILITIES] - assertEquals(caps[self_handle], caps_via_contacts_iface) + assertEquals(basic_caps, caps_via_contacts_iface) advertise_caps(q, bus, conn, service, [bidir_daap_fixed_properties], @@ -394,8 +366,8 @@ def test(q, bus, conn): conn.Connect() q.expect('dbus-signal', signal='StatusChanged', args=[0, 0]) - self_handle = conn.GetSelfHandle() - self_handle_name = conn.InspectHandles(1, [self_handle])[0] + self_handle = conn.Properties.Get(cs.CONN, "SelfHandle") + self_handle_name = conn.Properties.Get(cs.CONN, "SelfID") AvahiListener(q).listen_for_service("_presence._tcp") e = q.expect('service-added', name = self_handle_name, diff --git a/tests/twisted/avahi/file-transfer/send-file-to-unknown-contact.py b/tests/twisted/avahi/file-transfer/send-file-to-unknown-contact.py index 14f95242..cb5c64f9 100644 --- a/tests/twisted/avahi/file-transfer/send-file-to-unknown-contact.py +++ b/tests/twisted/avahi/file-transfer/send-file-to-unknown-contact.py @@ -14,7 +14,7 @@ class SendFileTransferToUnknownContactTest(SendFileTest): def my_request_ft_channel(self): self.contact_name = '%s@%s' % (self.CONTACT_NAME, get_host_name()) - self.handle = self.conn.RequestHandles(cs.HT_CONTACT, [self.contact_name])[0] + self.handle = self.conn.Contacts.GetContactByID(self.contact_name, [])[0] try: self.request_ft_channel() diff --git a/tests/twisted/avahi/ichat-composing.py b/tests/twisted/avahi/ichat-composing.py index b47ad898..ae48d8a8 100644 --- a/tests/twisted/avahi/ichat-composing.py +++ b/tests/twisted/avahi/ichat-composing.py @@ -28,8 +28,8 @@ def test(q, bus, conn): handle = wait_for_contact_in_publish(q, bus, conn, contact_name) - self_handle = conn.GetSelfHandle() - self_handle_name = conn.InspectHandles(cs.HT_CONTACT, [self_handle])[0] + self_handle = conn.Properties.Get(cs.CONN, "SelfHandle") + self_handle_name = conn.Properties.Get(cs.CONN, "SelfID") AvahiListener(q).listen_for_service("_presence._tcp") e = q.expect('service-added', name = self_handle_name, diff --git a/tests/twisted/avahi/ichat-incoming-msg.py b/tests/twisted/avahi/ichat-incoming-msg.py index 5f9027fa..71812230 100644 --- a/tests/twisted/avahi/ichat-incoming-msg.py +++ b/tests/twisted/avahi/ichat-incoming-msg.py @@ -21,8 +21,8 @@ def test(q, bus, conn): q.expect('dbus-signal', signal='StatusChanged', args=[0L, 0L]) basic_txt = { "txtvers": "1", "status": "avail" } - self_handle = conn.GetSelfHandle() - self_handle_name = conn.InspectHandles(cs.HT_CONTACT, [self_handle])[0] + self_handle = conn.Properties.Get(cs.CONN, "SelfHandle") + self_handle_name = conn.Properties.Get(cs.CONN, "SelfID") contact_name = "test-ichat-incoming-msg@" + get_host_name() listener, port = setup_stream_listener(q, contact_name) diff --git a/tests/twisted/avahi/muc-invite.py b/tests/twisted/avahi/muc-invite.py index 0cafad00..abfc8f28 100644 --- a/tests/twisted/avahi/muc-invite.py +++ b/tests/twisted/avahi/muc-invite.py @@ -27,8 +27,8 @@ def test(q, bus, conn): q.expect('dbus-signal', signal='StatusChanged', args=[0L, 0L]) basic_txt = { "txtvers": "1", "status": "avail" } - self_handle = conn.GetSelfHandle() - self_handle_name = conn.InspectHandles(HT_CONTACT, [self_handle])[0] + self_handle = conn.Properties.Get(cs.CONN, "SelfHandle") + self_handle_name = conn.Properties.Get(cs.CONN, "SelfID") contact_name = "test-muc@" + get_host_name() listener, port = setup_stream_listener(q, contact_name) @@ -79,14 +79,11 @@ def test(q, bus, conn): channel = make_channel_proxy(conn, path, "Channel") channel_group = make_channel_proxy(conn, path, "Channel.Interface.Group") - muc_handle = conn.RequestHandles(HT_ROOM, ['my-room'])[0] - # check channel properties # org.freedesktop.Telepathy.Channel D-Bus properties assert props[cs.CHANNEL_TYPE] == cs.CHANNEL_TYPE_TEXT assertContains(cs.CHANNEL_IFACE_GROUP, props[cs.INTERFACES]) assertContains(cs.CHANNEL_IFACE_MESSAGES, props[cs.INTERFACES]) - assert props[cs.TARGET_HANDLE] == muc_handle assert props[cs.TARGET_ID] == 'my-room' assert props[cs.TARGET_HANDLE_TYPE] == HT_ROOM assert props[cs.REQUESTED] == False diff --git a/tests/twisted/avahi/request-im.py b/tests/twisted/avahi/request-im.py index 97fc3402..d7d2141e 100644 --- a/tests/twisted/avahi/request-im.py +++ b/tests/twisted/avahi/request-im.py @@ -45,62 +45,9 @@ def test(q, bus, conn): ) in properties.get('RequestableChannelClasses'),\ properties['RequestableChannelClasses'] - # request a muc channel using the old API - handle = conn.RequestHandles(cs.HT_CONTACT, [contact_name])[0] - call_async(q, conn, 'RequestChannel', cs.CHANNEL_TYPE_TEXT, cs.HT_CONTACT, handle, True) - - ret, old_sig, new_sig = q.expect_many( - EventPattern('dbus-return', method='RequestChannel'), - EventPattern('dbus-signal', signal='NewChannel'), - EventPattern('dbus-signal', signal='NewChannels'), - ) - - path1 = ret.value[0] - chan = make_channel_proxy(conn, path1, "Channel") - - assert new_sig.args[0][0][0] == path1 - - props = new_sig.args[0][0][1] - assert props[tp_name_prefix + '.Channel.ChannelType'] ==\ - cs.CHANNEL_TYPE_TEXT - assert props[tp_name_prefix + '.Channel.TargetHandleType'] == cs.HT_CONTACT - assert props[tp_name_prefix + '.Channel.TargetHandle'] == handle - assert props[tp_name_prefix + '.Channel.TargetID'] == contact_name - assert props[tp_name_prefix + '.Channel.Requested'] == True - assert props[tp_name_prefix + '.Channel.InitiatorHandle'] \ - == conn.GetSelfHandle() - assert props[tp_name_prefix + '.Channel.InitiatorID'] \ - == self_name - - assert old_sig.args[0] == path1 - assert old_sig.args[1] == cs.CHANNEL_TYPE_TEXT - assert old_sig.args[2] == cs.HT_CONTACT # handle type - assert old_sig.args[3] == handle # handle - - # Exercise basic Channel Properties from spec 0.17.7 - channel_props = chan.GetAll( - tp_name_prefix + '.Channel', - dbus_interface='org.freedesktop.DBus.Properties') - assert channel_props.get('TargetHandle') == handle,\ - channel_props.get('TargetHandle') - assert channel_props['TargetID'] == contact_name, channel_props - assert channel_props.get('TargetHandleType') == cs.HT_CONTACT,\ - channel_props.get('TargetHandleType') - assert channel_props.get('ChannelType') == \ - cs.CHANNEL_TYPE_TEXT, channel_props.get('ChannelType') - assert channel_props['Requested'] == True - assert channel_props['InitiatorID'] == self_name - assert channel_props['InitiatorHandle'] == conn.GetSelfHandle() - + # create muc channel requestotron = dbus.Interface(conn, tp_name_prefix + '.Connection.Interface.Requests') - - chan.Close() - q.expect_many( - EventPattern('dbus-signal', signal='ChannelClosed', args=[path1]), - EventPattern('dbus-signal', signal='Closed', path=path1)) - - # create muc channel using new API call_async(q, requestotron, 'CreateChannel', { tp_name_prefix + '.Channel.ChannelType': cs.CHANNEL_TYPE_TEXT, @@ -108,9 +55,8 @@ def test(q, bus, conn): tp_name_prefix + '.Channel.TargetID': contact_name, }) - ret, old_sig, new_sig = q.expect_many( + ret, new_sig = q.expect_many( EventPattern('dbus-return', method='CreateChannel'), - EventPattern('dbus-signal', signal='NewChannel'), EventPattern('dbus-signal', signal='NewChannels'), ) path2 = ret.value[0] @@ -124,19 +70,13 @@ def test(q, bus, conn): assert props[tp_name_prefix + '.Channel.TargetID'] == contact_name assert props[tp_name_prefix + '.Channel.Requested'] == True assert props[tp_name_prefix + '.Channel.InitiatorHandle'] \ - == conn.GetSelfHandle() + == conn.Properties.Get(cs.CONN, "SelfHandle") assert props[tp_name_prefix + '.Channel.InitiatorID'] \ == self_name assert new_sig.args[0][0][0] == path2 assert new_sig.args[0][0][1] == props - assert old_sig.args[0] == path2 - assert old_sig.args[1] == cs.CHANNEL_TYPE_TEXT - assert old_sig.args[2] == cs.HT_CONTACT # handle type - assert old_sig.args[3] == handle # handle - assert old_sig.args[4] == True # suppress handler - # ensure roomlist channel yours, ensured_path, ensured_props = requestotron.EnsureChannel( { tp_name_prefix + '.Channel.ChannelType': diff --git a/tests/twisted/avahi/request-muc.py b/tests/twisted/avahi/request-muc.py index d3ad76cd..a6283b2e 100644 --- a/tests/twisted/avahi/request-muc.py +++ b/tests/twisted/avahi/request-muc.py @@ -38,53 +38,6 @@ def test(q, bus, conn): ) in properties.get('RequestableChannelClasses'),\ properties['RequestableChannelClasses'] - # request a muc channel using the old API - handle = conn.RequestHandles(cs.HT_ROOM, ['my-first-room'])[0] - call_async(q, conn, 'RequestChannel', cs.CHANNEL_TYPE_TEXT, cs.HT_ROOM, handle, True) - - ret, old_sig, new_sig = q.expect_many( - EventPattern('dbus-return', method='RequestChannel'), - EventPattern('dbus-signal', signal='NewChannel'), - EventPattern('dbus-signal', signal='NewChannels'), - ) - - path1 = ret.value[0] - chan = make_channel_proxy(conn, path1, "Channel") - - assert new_sig.args[0][0][0] == path1 - - props = new_sig.args[0][0][1] - assert props[tp_name_prefix + '.Channel.ChannelType'] ==\ - cs.CHANNEL_TYPE_TEXT - assert props[tp_name_prefix + '.Channel.TargetHandleType'] == cs.HT_ROOM - assert props[tp_name_prefix + '.Channel.TargetHandle'] == handle - assert props[tp_name_prefix + '.Channel.TargetID'] == 'my-first-room' - assert props[tp_name_prefix + '.Channel.Requested'] == True - assert props[tp_name_prefix + '.Channel.InitiatorHandle'] \ - == conn.GetSelfHandle() - assert props[tp_name_prefix + '.Channel.InitiatorID'] \ - == self_name - - assert old_sig.args[0] == path1 - assert old_sig.args[1] == cs.CHANNEL_TYPE_TEXT - assert old_sig.args[2] == cs.HT_ROOM # handle type - assert old_sig.args[3] == handle # handle - - # Exercise basic Channel Properties from spec 0.17.7 - channel_props = chan.GetAll( - tp_name_prefix + '.Channel', - dbus_interface='org.freedesktop.DBus.Properties') - assert channel_props.get('TargetHandle') == handle,\ - channel_props.get('TargetHandle') - assert channel_props['TargetID'] == 'my-first-room', channel_props - assert channel_props.get('TargetHandleType') == cs.HT_ROOM,\ - channel_props.get('TargetHandleType') - assert channel_props.get('ChannelType') == \ - cs.CHANNEL_TYPE_TEXT, channel_props.get('ChannelType') - assert channel_props['Requested'] == True - assert channel_props['InitiatorID'] == self_name - assert channel_props['InitiatorHandle'] == conn.GetSelfHandle() - requestotron = dbus.Interface(conn, tp_name_prefix + '.Connection.Interface.Requests') @@ -96,38 +49,29 @@ def test(q, bus, conn): tp_name_prefix + '.Channel.TargetID': 'my-second-room', }) - ret, old_sig, new_sig = q.expect_many( + ret, new_sig = q.expect_many( EventPattern('dbus-return', method='CreateChannel'), - EventPattern('dbus-signal', signal='NewChannel'), EventPattern('dbus-signal', signal='NewChannels'), ) path2 = ret.value[0] chan = make_channel_proxy(conn, path2, "Channel") - handle = conn.RequestHandles(cs.HT_ROOM, ['my-second-room'])[0] - props = ret.value[1] assert props[tp_name_prefix + '.Channel.ChannelType'] ==\ cs.CHANNEL_TYPE_TEXT assert props[tp_name_prefix + '.Channel.TargetHandleType'] == cs.HT_ROOM - assert props[tp_name_prefix + '.Channel.TargetHandle'] == handle assert props[tp_name_prefix + '.Channel.TargetID'] == 'my-second-room' assert props[tp_name_prefix + '.Channel.Requested'] == True assert props[tp_name_prefix + '.Channel.InitiatorHandle'] \ - == conn.GetSelfHandle() + == conn.Properties.Get(cs.CONN, "SelfHandle") assert props[tp_name_prefix + '.Channel.InitiatorID'] \ == self_name assert new_sig.args[0][0][0] == path2 assert new_sig.args[0][0][1] == props - assert old_sig.args[0] == path2 - assert old_sig.args[1] == cs.CHANNEL_TYPE_TEXT - assert old_sig.args[2] == cs.HT_ROOM # handle type - assert old_sig.args[3] == handle # handle - assert old_sig.args[4] == True # suppress handler - # ensure roomlist channel + handle = props[tp_name_prefix + '.Channel.TargetHandle'] yours, ensured_path, ensured_props = ret.value = requestotron.EnsureChannel( { tp_name_prefix + '.Channel.ChannelType': cs.CHANNEL_TYPE_TEXT, @@ -142,10 +86,7 @@ def test(q, bus, conn): q.expect_many( EventPattern('dbus-signal', signal='Closed', - path=path1), - EventPattern('dbus-signal', signal='Closed', path=path2), - EventPattern('dbus-signal', signal='ChannelClosed', args=[path1]), EventPattern('dbus-signal', signal='ChannelClosed', args=[path2]), EventPattern('dbus-signal', signal='StatusChanged', args=[2, 1]), ) diff --git a/tests/twisted/avahi/roomlist.py b/tests/twisted/avahi/roomlist.py index 5930fdb6..7e84a1be 100644 --- a/tests/twisted/avahi/roomlist.py +++ b/tests/twisted/avahi/roomlist.py @@ -36,72 +36,6 @@ def test(q, bus, conn): ) in properties.get('RequestableChannelClasses'),\ properties['RequestableChannelClasses'] - # request a roomlist channel using the old API - call_async(q, conn, 'RequestChannel', cs.CHANNEL_TYPE_ROOMLIST, 0, 0, True) - - ret, old_sig, new_sig = q.expect_many( - EventPattern('dbus-return', method='RequestChannel'), - EventPattern('dbus-signal', signal='NewChannel'), - EventPattern('dbus-signal', signal='NewChannels'), - ) - - path1 = ret.value[0] - chan = wrap_channel(bus.get_object(conn.bus_name, path1), "RoomList") - - assert new_sig.args[0][0][0] == path1 - - props = new_sig.args[0][0][1] - assert props[tp_name_prefix + '.Channel.ChannelType'] ==\ - cs.CHANNEL_TYPE_ROOMLIST - assert props[tp_name_prefix + '.Channel.TargetHandleType'] == 0 - assert props[tp_name_prefix + '.Channel.TargetHandle'] == 0 - assert props[tp_name_prefix + '.Channel.TargetID'] == '' - assert props[tp_name_prefix + '.Channel.Requested'] == True - assert props[tp_name_prefix + '.Channel.InitiatorHandle'] \ - == conn.GetSelfHandle() - assert props[tp_name_prefix + '.Channel.InitiatorID'] \ - == self_name - assert props[tp_name_prefix + '.Channel.Type.RoomList.Server'] == '' - - assert old_sig.args[0] == path1 - assert old_sig.args[1] == cs.CHANNEL_TYPE_ROOMLIST - assert old_sig.args[2] == 0 # handle type - assert old_sig.args[3] == 0 # handle - assert old_sig.args[4] == 1 # suppress handler - - # Exercise basic Channel Properties from spec 0.17.7 - channel_props = chan.Properties.GetAll( - tp_name_prefix + '.Channel', - dbus_interface='org.freedesktop.DBus.Properties') - assert channel_props.get('TargetHandle') == 0,\ - channel_props.get('TargetHandle') - assert channel_props['TargetID'] == '', channel_props - assert channel_props.get('TargetHandleType') == 0,\ - channel_props.get('TargetHandleType') - assert channel_props.get('ChannelType') == \ - cs.CHANNEL_TYPE_ROOMLIST, channel_props.get('ChannelType') - assert channel_props['Requested'] == True - assert channel_props['InitiatorID'] == self_name - assert channel_props['InitiatorHandle'] == conn.GetSelfHandle() - - assert chan.Get( - cs.CHANNEL_TYPE_ROOMLIST, 'Server', - dbus_interface='org.freedesktop.DBus.Properties') == '' - - # list rooms - chan.RoomList.ListRooms() - - q.expect('dbus-signal', signal='ListingRooms', args=[True]) - - e = q.expect('dbus-signal', signal='GotRooms') - rooms = e.args[0] - # FIXME: this will fail if there is room announced on the network - #assert rooms == [] - - q.expect('dbus-signal', signal='ListingRooms', args=[False]) - - # FIXME: announce some Clique rooms and check is they are properly listed - requestotron = dbus.Interface(conn, tp_name_prefix + '.Connection.Interface.Requests') @@ -112,9 +46,8 @@ def test(q, bus, conn): tp_name_prefix + '.Channel.TargetHandleType': 0, }) - ret, old_sig, new_sig = q.expect_many( + ret, new_sig = q.expect_many( EventPattern('dbus-return', method='CreateChannel'), - EventPattern('dbus-signal', signal='NewChannel'), EventPattern('dbus-signal', signal='NewChannels'), ) path2 = ret.value[0] @@ -128,7 +61,7 @@ def test(q, bus, conn): assert props[tp_name_prefix + '.Channel.TargetID'] == '' assert props[tp_name_prefix + '.Channel.Requested'] == True assert props[tp_name_prefix + '.Channel.InitiatorHandle'] \ - == conn.GetSelfHandle() + == conn.Properties.Get(cs.CONN, "SelfHandle") assert props[tp_name_prefix + '.Channel.InitiatorID'] \ == self_name assert props[tp_name_prefix + '.Channel.Type.RoomList.Server'] == '' @@ -136,12 +69,6 @@ def test(q, bus, conn): assert new_sig.args[0][0][0] == path2 assert new_sig.args[0][0][1] == props - assert old_sig.args[0] == path2 - assert old_sig.args[1] == cs.CHANNEL_TYPE_ROOM_LIST - assert old_sig.args[2] == 0 # handle type - assert old_sig.args[3] == 0 # handle - assert old_sig.args[4] == 1 # suppress handler - assert chan2.Properties.Get(cs.CHANNEL_TYPE_ROOM_LIST, 'Server') == '' # ensure roomlist channel @@ -165,9 +92,6 @@ def test(q, bus, conn): conn.Disconnect() q.expect_many( - EventPattern('dbus-signal', signal='Closed', - path=path1), - EventPattern('dbus-signal', signal='ChannelClosed', args=[path1]), EventPattern('dbus-signal', signal='StatusChanged', args=[2, 1]), ) diff --git a/tests/twisted/avahi/set-presence.py b/tests/twisted/avahi/set-presence.py index 16ecfb75..82343c4b 100644 --- a/tests/twisted/avahi/set-presence.py +++ b/tests/twisted/avahi/set-presence.py @@ -14,8 +14,8 @@ def test(q, bus, conn): conn.Connect() q.expect('dbus-signal', signal='StatusChanged', args=[cs.CONN_STATUS_CONNECTED, cs.CSR_NONE_SPECIFIED]) - self_handle = conn.GetSelfHandle() - self_handle_name = conn.InspectHandles(cs.HT_CONTACT, [self_handle])[0] + self_handle = conn.Properties.Get(cs.CONN, "SelfHandle") + self_handle_name = conn.Properties.Get(cs.CONN, "SelfID") AvahiListener(q).listen_for_service("_presence._tcp") e = q.expect('service-added', name = self_handle_name, protocol = avahi.PROTO_INET) diff --git a/tests/twisted/avahi/text-channel.py b/tests/twisted/avahi/text-channel.py index 7ce5adb8..b37b1c2f 100644 --- a/tests/twisted/avahi/text-channel.py +++ b/tests/twisted/avahi/text-channel.py @@ -29,8 +29,10 @@ def test(q, bus, conn): handle = wait_for_contact_in_publish(q, bus, conn, contact_name) - t = conn.RequestChannel(cs.CHANNEL_TYPE_TEXT, cs.HT_CONTACT, handle, - True) + t = conn.Requests.CreateChannel({ + cs.CHANNEL_TYPE: cs.CHANNEL_TYPE_TEXT, + cs.TARGET_HANDLE_TYPE: cs.HT_CONTACT, + cs.TARGET_HANDLE: handle})[0] text_channel = make_channel_proxy(conn, t, "Channel.Type.Text") text_channel.Send(cs.MT_NORMAL, INCOMING_MESSAGE) @@ -46,8 +48,8 @@ def test(q, bus, conn): incoming.transport.loseConnection() # Now send a message to salut - self_handle = conn.GetSelfHandle() - self_handle_name = conn.InspectHandles(cs.HT_CONTACT, [self_handle])[0] + self_handle = conn.Properties.Get(cs.CONN, "SelfHandle") + self_handle_name = conn.Properties.Get(cs.CONN, "SelfID") AvahiListener(q).listen_for_service("_presence._tcp") diff --git a/tests/twisted/avahi/tubes/request-muc-tubes.py b/tests/twisted/avahi/tubes/request-muc-tubes.py index b57ae98e..21100f15 100644 --- a/tests/twisted/avahi/tubes/request-muc-tubes.py +++ b/tests/twisted/avahi/tubes/request-muc-tubes.py @@ -39,30 +39,28 @@ def test(q, bus, conn): cs.STREAM_TUBE_SERVICE: 'loldongs', }) - ret, old_sig, new_sig = q.expect_many( + ret, new_sig = q.expect_many( EventPattern('dbus-return', method='CreateChannel'), - EventPattern('dbus-signal', signal='NewChannel'), EventPattern('dbus-signal', signal='NewChannels'), ) tube_path = ret.value[0] chan = wrap_channel(bus.get_object(conn.bus_name, tube_path), 'StreamTube') - handle = conn.RequestHandles(cs.HT_ROOM, ['my-second-room'])[0] - tube_props = ret.value[1] assert tube_props[cs.CHANNEL_TYPE] == cs.CHANNEL_TYPE_STREAM_TUBE assert tube_props[cs.TARGET_HANDLE_TYPE] == cs.HT_ROOM - assert tube_props[cs.TARGET_HANDLE] == handle assert tube_props[cs.TARGET_ID] == 'my-second-room' assert tube_props[cs.REQUESTED] == True - assert tube_props[cs.INITIATOR_HANDLE] == conn.GetSelfHandle() + assert tube_props[cs.INITIATOR_HANDLE] == conn.Properties.Get(cs.CONN, "SelfHandle") assert tube_props[cs.INITIATOR_ID] == self_name # text and tube channels are announced channels = new_sig.args[0] assert len(channels) == 1 + handle = tube_props[cs.TARGET_HANDLE] + path, props = channels[0] assert props[cs.CHANNEL_TYPE] == cs.CHANNEL_TYPE_STREAM_TUBE assert path == tube_path @@ -70,7 +68,7 @@ def test(q, bus, conn): assert props[cs.TARGET_HANDLE_TYPE] == cs.HT_ROOM assert props[cs.TARGET_HANDLE] == handle assert props[cs.TARGET_ID] == 'my-second-room' - assert props[cs.INITIATOR_HANDLE] == conn.GetSelfHandle() + assert props[cs.INITIATOR_HANDLE] == conn.Properties.Get(cs.CONN, "SelfHandle") assert props[cs.INITIATOR_ID] == self_name # ensure the same channel diff --git a/tests/twisted/avahi/tubes/tubetestutil.py b/tests/twisted/avahi/tubes/tubetestutil.py index bec6ad48..d058ef62 100644 --- a/tests/twisted/avahi/tubes/tubetestutil.py +++ b/tests/twisted/avahi/tubes/tubetestutil.py @@ -79,7 +79,7 @@ def connect_two_accounts(q, bus, conn): return contact1_name, conn2, contact2_name, contact2_handle_on_conn1, contact1_handle_on_conn2 def join_muc(q, conn, muc_name): - self_handle = conn.GetSelfHandle() + self_handle = conn.Properties.Get(cs.CONN, "SelfHandle") muc_handle = conn.RequestHandles(cs.HT_ROOM, [muc_name])[0] path = conn.RequestChannel(cs.CHANNEL_TYPE_TEXT, cs.HT_ROOM, muc_handle, True) # added as remote pending @@ -103,7 +103,7 @@ def invite_to_muc(q, group1, conn2, invited_handle, inviter_handle): # we are invited to the muc # added as local pending - conn2_self_handle = conn2.GetSelfHandle() + conn2_self_handle = conn2.Properties.Get(cs.CONN, "SelfHandle") q.expect('dbus-signal', signal='MembersChanged', path=path, args=["Let's tube!", [], [], [conn2_self_handle], [], inviter_handle, 4]) diff --git a/tests/twisted/avahi/tubes/two-muc-dbus-tubes.py b/tests/twisted/avahi/tubes/two-muc-dbus-tubes.py index 3d33a5bb..6fc81097 100644 --- a/tests/twisted/avahi/tubes/two-muc-dbus-tubes.py +++ b/tests/twisted/avahi/tubes/two-muc-dbus-tubes.py @@ -49,8 +49,8 @@ def test(q, bus, conn): contact1_name, conn2, contact2_name, contact2_handle_on_conn1,\ contact1_handle_on_conn2 = t.connect_two_accounts(q, bus, conn) - conn1_self_handle = conn.GetSelfHandle() - conn2_self_handle = conn2.GetSelfHandle() + conn1_self_handle = conn.Properties.Get(cs.CONN, "SelfHandle") + conn2_self_handle = conn2.Properties.Get(cs.CONN, "SelfHandle") # first connection: join muc muc_handle1, group1 = t.join_muc(q, conn, muc_name) diff --git a/tests/twisted/avahi/tubes/two-muc-stream-tubes.py b/tests/twisted/avahi/tubes/two-muc-stream-tubes.py index 2e3bae53..a193bea2 100644 --- a/tests/twisted/avahi/tubes/two-muc-stream-tubes.py +++ b/tests/twisted/avahi/tubes/two-muc-stream-tubes.py @@ -76,7 +76,7 @@ def test(q, bus, conn): contact1_name, conn2, contact2_name, contact2_handle_on_conn1,\ contact1_handle_on_conn2 = t.connect_two_accounts(q, bus, conn) - conn1_self_handle = conn.GetSelfHandle() + conn1_self_handle = conn.Properties.Get(cs.CONN, "SelfHandle") # request a stream tube channel (new API) conn.Requests.CreateChannel({ diff --git a/tests/twisted/cm/protocol.py b/tests/twisted/cm/protocol.py index 51bf6d62..6f62f1ec 100644 --- a/tests/twisted/cm/protocol.py +++ b/tests/twisted/cm/protocol.py @@ -18,13 +18,8 @@ def test(q, bus, conn): protocols = unwrap(cm_prop_iface.Get(cs.CM, 'Protocols')) assertEquals(set(['local-xmpp']), set(protocols.keys())) - protocol_names = unwrap(cm_iface.ListProtocols()) - assertEquals(set(['local-xmpp']), set(protocol_names)) - - cm_params = cm_iface.GetParameters('local-xmpp') local_props = protocols['local-xmpp'] local_params = local_props[cs.PROTOCOL + '.Parameters'] - assertEquals(cm_params, local_params) proto = bus.get_object(cm.bus_name, cm.object_path + '/local_xmpp') proto_iface = dbus.Interface(proto, cs.PROTOCOL) diff --git a/tests/twisted/servicetest.py b/tests/twisted/servicetest.py index 1771ddaf..bca3b13b 100644 --- a/tests/twisted/servicetest.py +++ b/tests/twisted/servicetest.py @@ -427,8 +427,6 @@ class ProxyWrapper: self.object = object self.default_interface = dbus.Interface(object, default) self.Properties = dbus.Interface(object, dbus.PROPERTIES_IFACE) - self.TpProperties = \ - dbus.Interface(object, tp_name_prefix + '.Properties') self.interfaces = dict([ (name, dbus.Interface(object, iface)) for name, iface in others.iteritems()]) |