~ubuntu-branches/ubuntu/maverick/telepathy-salut/maverick

« back to all changes in this revision

Viewing changes to tests/twisted/avahi/tubes-to-nonexistant-ids.py

  • Committer: Bazaar Package Importer
  • Author(s): Simon McVittie
  • Date: 2009-09-10 10:50:03 UTC
  • mfrom: (1.3.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20090910105003-0kn45hhoocf4m37i
* New upstream release
* Bump build-dependency versions to Python 2.5 and telepathy-glib 0.7.36
* Standards-Version: 3.8.3 (no changes)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
"""
2
 
Test that requests for Tubes and StreamTube channels to ids which aren't
3
 
actually on the network fail gracefully with NotAvailable
4
 
"""
5
 
 
6
 
from saluttest import exec_test
7
 
 
8
 
from constants import (
9
 
    HT_CONTACT, CONN_IFACE_REQUESTS,
10
 
    CHANNEL_TYPE, TARGET_HANDLE_TYPE, TARGET_HANDLE,
11
 
    CHANNEL_TYPE_TUBES, CHANNEL_TYPE_STREAM_TUBE,
12
 
    NOT_AVAILABLE
13
 
    )
14
 
 
15
 
import dbus
16
 
 
17
 
arbitrary_ids = [ "DooN4Bei@TheeK6bo-Tegh4aci", "ahrui1iM@Dai6igho-ADetaes3" ]
18
 
 
19
 
print "FIXME: test-to-nonexistant-ids.py disabled because 1-1 tubes are disabled for now"
20
 
# exiting 77 causes automake to consider the test to have been skipped
21
 
raise SystemExit(77)
22
 
 
23
 
def test(q, bus, conn):
24
 
    conn.Connect()
25
 
    q.expect('dbus-signal', signal='StatusChanged', args=[0L, 0L])
26
 
 
27
 
    h1, h2 = conn.RequestHandles(HT_CONTACT, arbitrary_ids)
28
 
 
29
 
    try:
30
 
        conn.RequestChannel(CHANNEL_TYPE_TUBES, HT_CONTACT, h1, True)
31
 
    except dbus.DBusException, e:
32
 
        assert e.get_dbus_name() == NOT_AVAILABLE, e.get_dbus_name()
33
 
    else:
34
 
        assert False, "Should raise NotAvailable error"
35
 
 
36
 
    requestotron = dbus.Interface(conn, CONN_IFACE_REQUESTS)
37
 
 
38
 
    try:
39
 
        requestotron.CreateChannel({
40
 
            CHANNEL_TYPE: CHANNEL_TYPE_STREAM_TUBE,
41
 
            TARGET_HANDLE_TYPE: HT_CONTACT,
42
 
            TARGET_HANDLE: h2,
43
 
            CHANNEL_TYPE_STREAM_TUBE + ".Service": "com.example",
44
 
        })
45
 
    except dbus.DBusException, e:
46
 
        assert e.get_dbus_name() == NOT_AVAILABLE, e.get_dbus_name()
47
 
    else:
48
 
        assert False, "Should raise NotAvailable error"
49
 
 
50
 
    conn.Disconnect()
51
 
    q.expect('dbus-signal', signal='StatusChanged', args=[2, 1])
52
 
 
53
 
if __name__ == '__main__':
54
 
    exec_test(test)