~didrocks/ubuntuone-client/use_result_var

« back to all changes in this revision

Viewing changes to tests/syncdaemon/test_main.py

  • Committer: Bazaar Package Importer
  • Author(s): Rodney Dawes
  • Date: 2011-01-25 16:42:52 UTC
  • mfrom: (1.1.43 upstream)
  • Revision ID: james.westby@ubuntu.com-20110125164252-gyx1hii7jk1b3hw7
Tags: 1.5.3-0ubuntu1
* New upstream release.
  - Metadata load is too slow (LP: #436612)
  - Out of space dialog is broken (LP: #650671)
  - Should not autoconnect when there are no credentials (LP: #701588)
  - gsd extension should not ask for sso credentials (LP: #702171) 

Show diffs side-by-side

added added

removed removed

Lines of Context:
91
91
        self.assertTrue(self.restarted)
92
92
        main.shutdown()
93
93
 
 
94
    def test_shutdown_pushes_sys_quit(self):
 
95
        """When shutting down, the SYS_QUIT event is pushed."""
 
96
        main = self.build_main()
 
97
        events = []
 
98
        self.patch(main.event_q, 'push',
 
99
                   lambda *a, **kw: events.append((a, kw)))
 
100
 
 
101
        main.shutdown()
 
102
        expected = [(('SYS_USER_DISCONNECT',), {}), (('SYS_QUIT',), {})]
 
103
        self.assertEqual(expected, events)
 
104
 
94
105
    def test_handshake_timeout(self):
95
106
        """Check connecting times out."""
96
107
        d0 = defer.Deferred()
101
112
                """Pass the test when we get this event."""
102
113
                reactor.callLater(0, d0.callback, None)
103
114
 
104
 
        main = self.build_main(handshake_timeout=.5)
 
115
        main = self.build_main(handshake_timeout=0)
105
116
 
106
117
        def fake_connect(*a):
107
118
            """Only connect when States told so."""
183
194
 
184
195
        self.connect_called = False
185
196
        self.patch(main_mod.ubuntuone.platform.ExternalInterface, 'connect',
186
 
                   lambda *a: setattr(self, 'connect_called', True))
 
197
                   lambda *a, **kw: setattr(self, 'connect_called', (a, kw)))
187
198
 
188
199
        main = self.build_main()
189
200
        self.addCleanup(lambda: main.shutdown())
190
201
 
191
 
        self.assertTrue(self.connect_called)
 
202
        self.assertEqual(self.connect_called, ((main.external,),
 
203
                                               {'autoconnecting': True}))
192
204
 
193
205
    def test_dont_connect_if_autoconnect_is_disabled(self):
194
206
        """If autoconnect option is disabled, do not connect the syncdaemon."""
199
211
 
200
212
        self.connect_called = False
201
213
        self.patch(main_mod.ubuntuone.platform.ExternalInterface, 'connect',
202
 
                   lambda *a: setattr(self, 'connect_called', True))
 
214
                   lambda *a, **kw: setattr(self, 'connect_called', True))
203
215
 
204
216
        main = self.build_main()
205
217
        self.addCleanup(lambda: main.shutdown())
219
231
        main = self.build_main()
220
232
        self.addCleanup(lambda: main.shutdown())
221
233
        self.assertNotIn(main.eventlog_listener, main.event_q._listeners)
 
234
 
 
235
    def test_status_listener_is_installed(self):
 
236
        """The status listener is installed if needed."""
 
237
        fake_get_listener = lambda *a: object()
 
238
        self.patch(main_mod.status_listener, "get_listener", fake_get_listener)
 
239
        main = self.build_main()
 
240
        self.addCleanup(lambda: main.shutdown())
 
241
        self.assertIn(main.status_listener, main.event_q._listeners)
 
242
 
 
243
    def test_status_listener_not_installed_when_disabled(self):
 
244
        """The status listener is not started if it's not available."""
 
245
        self.patch(main_mod.status_listener, "get_listener", lambda *a: None)
 
246
        main = self.build_main()
 
247
        self.addCleanup(lambda: main.shutdown())
 
248
        self.assertNotIn(main.status_listener, main.event_q._listeners)