~facundo/ubuntuone-client/fix-svfilenew-conflict

« back to all changes in this revision

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

  • Committer: Facundo Batista
  • Date: 2011-04-04 12:31:43 UTC
  • mfrom: (922.1.9 ubuntuone-client)
  • Revision ID: facundo@taniquetil.com.ar-20110404123143-mobua5abcpinz0o2
TrunkĀ mergedĀ in

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
from twisted.internet import defer, reactor
30
30
from twisted.python import failure
31
31
 
32
 
from ubuntu_sso.main import SSOCredentials
33
 
 
34
32
from contrib.testing.testcase import (
35
33
    BaseTwistedTestCase, FakeMain, FAKED_CREDENTIALS)
36
34
 
76
74
from ubuntuone.devtools.testcase import DBusTestCase
77
75
 
78
76
 
79
 
# OAuth stubs
80
 
class FakeLoginProcessor(object):
81
 
    """Stub login processor."""
82
 
 
83
 
    def __init__(self, dbus_object):
84
 
        """Initialize the login processor."""
85
 
        self.next_login_cb = None
86
 
 
87
 
    def login(self, realm, consumer_key, error_handler=None,
88
 
              reply_handler=None, do_login=True):
89
 
        """Stub, call self.next_login_cb or send NewCredentials if
90
 
        self.next_login_cb isn't defined.
91
 
        """
92
 
        self.realm = str(realm)
93
 
        self.consumer_key = str(consumer_key)
94
 
        if self.next_login_cb:
95
 
            cb = self.next_login_cb[0]
96
 
            args = self.next_login_cb[1]
97
 
            self.next_login_cb = None
98
 
            return cb(*args)
99
 
        else:
100
 
            self.dbus_object.NewCredentials(realm, consumer_key)
101
 
 
102
 
    def clear_token(self, realm, consumer_key):
103
 
        """Stub, do nothing"""
104
 
        pass
105
 
 
106
 
    def next_login_with(self, callback, args=tuple()):
107
 
        """shortcircuit the next call to login and call the specified callback.
108
 
        callback is usually one of: self.got_token, self.got_no_token,
109
 
        self.got_denial or self.got_error.
110
 
        """
111
 
        self.next_login_cb = (callback, args)
112
 
 
113
 
 
114
77
class FakeDBusInterface(object):
115
78
    """A fake DBusInterface..."""
116
79
 
204
167
            self.fail(str(error))
205
168
 
206
169
 
207
 
class FakeLogin(SSOCredentials):
208
 
    """Stub Object which listens for D-Bus OAuth requests"""
209
 
 
210
 
    def __init__(self, bus):
211
 
        """Initiate the object."""
212
 
        self.bus = bus
213
 
        self.busName = dbus.service.BusName(DBUS_CREDENTIALS_IFACE,
214
 
                                            bus=self.bus)
215
 
        # bypass the parent class __init__ as it has the path hardcoded
216
 
        # and we can't use '/' as the path, as we are already using it
217
 
        # for syncdaemon. pylint: disable-msg=W0233,W0231
218
 
        dbus.service.Object.__init__(self, object_path="/oauthdesktop",
219
 
                                     bus_name=self.busName)
220
 
        self.processor = FakeLoginProcessor(self)
221
 
        self.currently_authing = False
222
 
 
223
 
    def shutdown(self):
224
 
        """Shutdown and remove any trace from the bus"""
225
 
        self.busName.get_bus().release_name(self.busName.get_name())
226
 
        self.remove_from_connection()
227
 
 
228
 
 
229
170
class FakeNetworkManager(DBusExposedObject):
230
171
    """ A fake NetworkManager that only emits StatusChanged signal. """
231
172