~didrocks/ubuntuone-client/use_result_var

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Rodney Dawes
  • Date: 2011-02-11 16:18:11 UTC
  • mto: This revision was merged to the branch mainline in revision 67.
  • Revision ID: james.westby@ubuntu.com-20110211161811-n18dj9lde7dxqjzr
Tags: upstream-1.5.4
ImportĀ upstreamĀ versionĀ 1.5.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
291
291
class WatchTests(BaseFSMonitorTestCase):
292
292
    """Test the EQ API to add and remove watchs."""
293
293
 
 
294
    @defer.inlineCallbacks
294
295
    def _create_udf(self, path):
295
296
        """Create an UDF and returns it and the volume"""
296
297
        os.makedirs(path)
297
298
        udf = volume_manager.UDF("vol_id", "node_id", path.decode('utf-8'),
298
299
                                 path, True)
299
 
        self.vm.add_udf(udf)
 
300
        yield self.vm.add_udf(udf)
300
301
 
301
302
    def test_add_general_watch(self):
302
303
        """Test that general watchs can be added."""
311
312
        # nothing in the udf ancestors watch
312
313
        self.assertEqual(self.monitor._ancestors_watchs, {})
313
314
 
 
315
    @defer.inlineCallbacks
314
316
    def test_add_watch_on_udf_ancestor(self):
315
317
        """Test that ancestors watchs can be added."""
316
318
        # create the udf and add the watch
317
319
        path_udf = os.path.join(self.home_dir, "path/to/UDF")
318
 
        self._create_udf(path_udf)
 
320
        yield self._create_udf(path_udf)
319
321
        path_ancestor = os.path.join(self.home_dir, "path")
320
322
        self.monitor.add_watch(path_ancestor)
321
323
 
327
329
        # nothing in the general watch
328
330
        self.assertEqual(self.monitor._general_watchs, {})
329
331
 
 
332
    @defer.inlineCallbacks
330
333
    def test_add_watch_on_udf_exact(self):
331
334
        """Test adding the watch exactly on UDF."""
332
335
        # create the udf and add the watch
333
336
        path_udf = os.path.join(self.home_dir, "path/to/UDF")
334
 
        self._create_udf(path_udf)
 
337
        yield self._create_udf(path_udf)
335
338
        self.monitor.add_watch(path_udf)
336
339
 
337
340
        # pylint: disable-msg=W0212
338
341
        self.assertTrue(path_udf in self.monitor._general_watchs)
339
342
        self.assertEqual(self.monitor._ancestors_watchs, {})
340
343
 
 
344
    @defer.inlineCallbacks
341
345
    def test_add_watch_on_udf_child(self):
342
346
        """Test adding the watch inside UDF."""
343
347
        # create the udf and add the watch
344
348
        path_udf = os.path.join(self.home_dir, "path/to/UDF")
345
 
        self._create_udf(path_udf)
 
349
        yield self._create_udf(path_udf)
346
350
        path_ancestor = os.path.join(self.home_dir, "path/to/UDF/inside")
347
351
        os.mkdir(path_ancestor)
348
352
        self.monitor.add_watch(path_ancestor)
364
368
        self.monitor.rm_watch(not_existing_dir)
365
369
        self.assertFalse(self.monitor.has_watch(not_existing_dir))
366
370
 
 
371
    @defer.inlineCallbacks
367
372
    def test_rm_watch_wrong(self):
368
373
        """Test that general watchs can be removed."""
369
374
        # add two types of watchs
370
375
        self.monitor.add_watch(self.root_dir)
371
376
        path_udf = os.path.join(self.home_dir, "path/to/UDF")
372
 
        self._create_udf(path_udf)
 
377
        yield self._create_udf(path_udf)
373
378
        path_ancestor = os.path.join(self.home_dir, "path")
374
379
        self.monitor.add_watch(path_ancestor)
375
380
 
388
393
        self.assertEqual(self.monitor._general_watchs, {})
389
394
        self.assertEqual(self.monitor._ancestors_watchs, {})
390
395
 
 
396
    @defer.inlineCallbacks
391
397
    def test_rm_watch_ancestor(self):
392
398
        """Test that ancestor watchs can be removed."""
393
399
        # create the udf and add the watch
394
400
        path_udf = os.path.join(self.home_dir, "path/to/UDF")
395
 
        self._create_udf(path_udf)
 
401
        yield self._create_udf(path_udf)
396
402
        path_ancestor = os.path.join(self.home_dir, "path")
397
403
        self.monitor.add_watch(path_ancestor)
398
404
 
414
420
        self.monitor.rm_watch(self.root_dir)
415
421
        self.assertFalse(self.monitor.has_watch(self.root_dir))
416
422
 
 
423
    @defer.inlineCallbacks
417
424
    def test_has_watch_ancestor(self):
418
425
        """Test that an ancestor path is watched."""
419
426
        path_udf = os.path.join(self.home_dir, "path/to/UDF")
420
 
        self._create_udf(path_udf)
 
427
        yield self._create_udf(path_udf)
421
428
        path_ancestor = os.path.join(self.home_dir, "path")
422
429
 
423
430
        self.assertFalse(self.monitor.has_watch(path_ancestor))