~ubuntu-branches/ubuntu/precise/ubuntuone-client/precise

« back to all changes in this revision

Viewing changes to tests/platform/linux/test_dbus.py

  • Committer: Package Import Robot
  • Author(s): Rodney Dawes
  • Date: 2012-02-23 12:02:01 UTC
  • mfrom: (1.1.61)
  • Revision ID: package-import@ubuntu.com-20120223120201-jvvog3kvj9vcvepj
Tags: 2.99.5-0ubuntu1
* New upstream release.
  - Call network_connected properly on all platforms. (LP: #885292)
  - Check whether to call handle_dir_delete in a better place.
  - Use glib reactor to run tests if release is < 12.04.
* debian/watch:
  - Update watch file for new release. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
39
39
    DBUS_IFACE_FOLDERS_NAME,
40
40
    DBUS_IFACE_PUBLIC_FILES_NAME,
41
41
    DBUS_IFACE_LAUNCHER_NAME,
42
 
    NM_STATE_CONNECTED_GLOBAL,
43
 
    NM_STATE_DISCONNECTED,
 
42
#    NM_STATE_CONNECTED_GLOBAL,
 
43
#    NM_STATE_DISCONNECTED,
44
44
)
45
45
from ubuntuone.platform.tools.linux import DBusClient
46
46
 
76
76
 
77
77
    def emit_connected(self):
78
78
        """ Emits the signal StateCganged(3). """
79
 
        self.StateChanged(NM_STATE_CONNECTED_GLOBAL)
 
79
        self.StateChanged(70)
80
80
 
81
81
    def emit_disconnected(self):
82
82
        """ Emits the signal StateCganged(4). """
83
 
        self.StateChanged(NM_STATE_DISCONNECTED)
 
83
        self.StateChanged(20)
84
84
 
85
85
    @dbus.service.method(dbus.PROPERTIES_IFACE,
86
86
                         in_signature='ss', out_signature='v',
95
95
    @dbus.service.method('org.freedesktop.NetworkManager')
96
96
    def state(self):
97
97
        """Fake the state."""
98
 
        return NM_STATE_CONNECTED_GLOBAL
 
98
        return 70
99
99
 
100
100
    # pylint: enable-msg=C0103
101
101
 
208
208
DBusTwistedTestCase = IPCTestCase  # API compatibility
209
209
 
210
210
 
211
 
class NetworkManagerIntegrationTests(IPCTestCase):
212
 
    """Test case for our NetworkManager integration."""
213
 
 
214
 
    def test_nm_signals(self):
215
 
        """Test that NM signals are received and handled properly."""
216
 
        result = None
217
 
        d = defer.Deferred()
218
 
 
219
 
        class Listener(object):
220
 
            """Helper class."""
221
 
 
222
 
            # class-closure, cannot use self, pylint: disable=E0213
223
 
            def handle_SYS_NET_CONNECTED(innerself):
224
 
                self.nm.emit_disconnected()
225
 
 
226
 
            def handle_SYS_NET_DISCONNECTED(innerself):
227
 
                self.assertTrue(result)
228
 
 
229
 
        listener = Listener()
230
 
        self.event_q.subscribe(listener)
231
 
 
232
 
        def empty_queue_cb():
233
 
            d.callback(True)
234
 
 
235
 
        def callback(result):
236
 
            self.event_q.unsubscribe(listener)
237
 
            self.event_q.remove_empty_event_queue_callback(empty_queue_cb)
238
 
        d.addCallback(callback)
239
 
 
240
 
        self.nm.emit_connected()
241
 
        self.event_q.add_empty_event_queue_callback(empty_queue_cb)
242
 
        return d
243
 
 
244
 
 
245
211
class StatusTestCase(IPCTestCase):
246
212
    """Tests for the Status exposed object."""
247
213