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

« back to all changes in this revision

Viewing changes to tests/syncdaemon/test_eventqueue.py

  • Committer: Bazaar Package Importer
  • Author(s): Rodney Dawes
  • Date: 2011-08-25 16:11:47 UTC
  • mfrom: (1.1.54 upstream)
  • Revision ID: james.westby@ubuntu.com-20110825161147-v6zedpznh2evnurj
Tags: 1.7.2-0ubuntu1
* New upstream release.
  - Work correctly with static and GI bindings of gobject (LP: #829186)

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
 
22
22
import logging
23
23
 
 
24
from twisted.internet import defer
 
25
from twisted.trial.unittest import TestCase
 
26
 
 
27
from contrib.testing.testcase import BaseTwistedTestCase, FakeVolumeManager
24
28
from ubuntuone.syncdaemon import (
25
29
    event_queue,
26
30
    filesystem_manager,
27
31
    tritcask,
28
32
)
29
 
from contrib.testing.testcase import BaseTwistedTestCase, FakeVolumeManager
30
 
from twisted.internet import defer
31
33
from ubuntuone.devtools.handlers import MementoHandler
32
34
 
33
35
 
379
381
 
380
382
        d.addCallback(callback)
381
383
        return d
 
384
 
 
385
 
 
386
class FakeMonitor(object):
 
387
    """A fake FilesystemMonitor."""
 
388
 
 
389
    def __init__(self, *args):
 
390
        """Initialize this fake."""
 
391
        self.shutdown_d = defer.Deferred()
 
392
 
 
393
    def shutdown(self):
 
394
        """Get the shutdown deferred."""
 
395
        return self.shutdown_d
 
396
 
 
397
 
 
398
class EventQueueShutdownTestCase(TestCase):
 
399
    """Test the shutdown method in EQ."""
 
400
 
 
401
    timeout = 2
 
402
 
 
403
    @defer.inlineCallbacks
 
404
    def test_shutdown_defers(self):
 
405
        """The shutdown method in eq defers on the shutdown of the monitor."""
 
406
        self.patch(event_queue, "FilesystemMonitor", FakeMonitor)
 
407
        eq = event_queue.EventQueue(None)
 
408
        d = eq.shutdown()
 
409
        self.assertFalse(d.called, "shutdown is fired after the monitor.")
 
410
        eq.monitor.shutdown_d.callback(True)
 
411
        self.assertTrue(d.called, "shutdown is fired after the monitor.")
 
412
        yield d