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

« back to all changes in this revision

Viewing changes to tests/platform/test_filesystem_notifications.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:
23
23
import unittest
24
24
 
25
25
from twisted.internet import defer, reactor
 
26
from ubuntuone.devtools.handlers import MementoHandler
 
27
from ubuntuone.devtools.testcase import skipIfOS
26
28
 
27
29
from tests.platform import _GeneralINotifyProcessor
28
30
from contrib.testing import testcase
 
31
from ubuntuone.platform import remove_file, remove_dir, rename
29
32
from ubuntuone.syncdaemon.tritcask import Tritcask
30
 
from ubuntuone.devtools.handlers import MementoHandler
31
 
from ubuntuone.devtools.testcase import skipIfOS
32
33
from ubuntuone.syncdaemon import (
33
34
    event_queue,
34
35
    filesystem_manager,
85
86
        self.vm = testcase.FakeVolumeManager(self.root_dir)
86
87
        self.tritcask_dir = self.mktemp("tritcask_dir")
87
88
        self.db = Tritcask(self.tritcask_dir)
 
89
        self.addCleanup(self.db.shutdown)
88
90
        self.fs = filesystem_manager.FileSystemManager(fsmdir, partials_dir,
89
91
                                                       self.vm, self.db)
90
92
        self.fs.create(path=self.root_dir, share_id='', is_dir=True)
101
103
 
102
104
        eq.subscribe(HitMe())
103
105
        self.monitor = eq.monitor
 
106
        self.addCleanup(self.monitor.shutdown)
104
107
        self.log_handler = MementoHandler()
105
108
        self.log_handler.setLevel(logging.DEBUG)
106
109
        self.monitor.log.addHandler(self.log_handler)
107
 
 
108
 
    @defer.inlineCallbacks
109
 
    def tearDown(self):
110
 
        """Clean up the tests."""
111
 
        self.monitor.shutdown()
112
 
        self.db.shutdown()
113
 
        self.monitor.log.removeHandler(self.log_handler)
114
 
        yield super(BaseFSMonitorTestCase, self).tearDown()
 
110
        self.addCleanup(self.monitor.log.removeHandler, self.log_handler)
115
111
 
116
112
 
117
113
class DynamicHitMe(object):
315
311
        yield self.monitor.add_watch(self.root_dir)
316
312
 
317
313
        # generate the event
318
 
        os.remove(testfile)
 
314
        remove_file(testfile)
319
315
        reactor.callLater(self.timeout - 0.2, self.check_filter)
320
316
        test_result = yield self._deferred
321
317
        defer.returnValue(test_result)
330
326
        yield self.monitor.add_watch(self.root_dir)
331
327
 
332
328
        # generate the event
333
 
        os.rmdir(testdir)
 
329
        remove_dir(testdir)
334
330
        reactor.callLater(self.timeout - 0.2, self.check_filter)
335
331
        test_result = yield self._deferred
336
332
        defer.returnValue(test_result)
351
347
        yield self.monitor.add_watch(self.root_dir)
352
348
 
353
349
        # generate the event
354
 
        os.rename(fromfile, tofile)
 
350
        rename(fromfile, tofile)
355
351
        reactor.callLater(self.timeout - 0.2, self.check_filter)
356
352
        test_result = yield self._deferred
357
353
        defer.returnValue(test_result)
372
368
        yield self.monitor.add_watch(self.root_dir)
373
369
 
374
370
        # generate the event
375
 
        os.rename(fromdir, todir)
 
371
        rename(fromdir, todir)
376
372
        reactor.callLater(self.timeout - 0.2, self.check_filter)
377
373
        test_result = yield self._deferred
378
374
        defer.returnValue(test_result)
393
389
        yield self.monitor.add_watch(self.root_dir)
394
390
 
395
391
        # generate the event
396
 
        os.rename(fromfile, tofile)
 
392
        rename(fromfile, tofile)
397
393
        reactor.callLater(self.timeout - 0.2, self.check_filter)
398
394
        test_result = yield self._deferred
399
395
        defer.returnValue(test_result)
412
408
        yield self.monitor.add_watch(root_dir)
413
409
 
414
410
        # generate the event
415
 
        os.rename(fromfile, tofile)
 
411
        rename(fromfile, tofile)
416
412
        reactor.callLater(self.timeout - 0.2, self.check_filter)
417
413
        test_result = yield self._deferred
418
414
        defer.returnValue(test_result)