~ahasenack/landscape-client/landscape-client-11.02

« back to all changes in this revision

Viewing changes to landscape/monitor/tests/test_mountinfo.py

  • Committer: Andreas Hasenack
  • Date: 2011-03-01 18:40:36 UTC
  • Revision ID: andreas@canonical.com-20110301184036-d34hjsrh38qxkgql
Imported changes from our production branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
    def setUp(self):
20
20
        LandscapeTest.setUp(self)
21
21
        self.mstore.set_accepted_types(["mount-info", "free-space"])
 
22
        self.log_helper.ignore_errors("Typelib file for namespace")
22
23
 
23
24
    def get_mount_info(self, *args, **kwargs):
24
25
        hal_devices = kwargs.pop("hal_devices", [])
365
366
        message = plugin.create_mount_info_message()
366
367
        self.assertEquals(message, None)
367
368
 
 
369
    def test_ignore_removable_devices_gudev(self):
 
370
        """
 
371
        The mount info plugin uses gudev to retrieve removable information
 
372
        about devices.
 
373
        """
 
374
        filename = self.makeFile("""\
 
375
/dev/scd0 /media/Xerox_M750 iso9660 ro,nosuid,nodev,uid=1000,utf8 0 0
 
376
""")
 
377
        plugin = self.get_mount_info(mounts_file=filename,
 
378
                                     mtab_file=filename)
 
379
        plugin._hal_manager = None
 
380
 
 
381
        class MockDevice(object):
 
382
            def get_sysfs_attr_as_boolean(self, attr):
 
383
                if attr == "removable":
 
384
                    return True
 
385
 
 
386
        class MockGudevClient(object):
 
387
            def query_by_device_file(self, name):
 
388
                if name == "/dev/scd0":
 
389
                    return MockDevice()
 
390
 
 
391
        plugin._gudev_client = MockGudevClient()
 
392
        self.monitor.add(plugin)
 
393
        plugin.run()
 
394
 
 
395
        message = plugin.create_mount_info_message()
 
396
        self.assertEquals(message, None)
 
397
 
368
398
    def test_ignore_multiparented_removable_devices(self):
369
399
        """
370
400
        Some removable devices might be the grand-children of a device that is