~ahasenack/landscape-client/landscape-client-11.07.1.1-0ubuntu0.10.10.0

« back to all changes in this revision

Viewing changes to landscape/lib/tests/test_disk.py

  • Committer: Bazaar Package Importer
  • Author(s): Free Ekanayaka
  • Date: 2010-04-21 19:58:10 UTC
  • mfrom: (1.1.16 upstream)
  • Revision ID: james.westby@ubuntu.com-20100421195810-s30uv3s6i27lue38
Tags: 1.5.2-0ubuntu0.10.10.0
* New upstream version (LP: #594594):
  - A new includes information about active network devices and their
    IP address in sysinfo output (LP: #272344).
  - A new plugin collects information about network traffic (#LP :284662).
  - Report information about which packages requested a reboot (LP: #538253).
  - Fix breakage on Lucid AMIs having no ramdisk (LP: #574810).
  - Migrate the inter-process communication system from DBus to Twisted AMP.

Show diffs side-by-side

added added

removed removed

Lines of Context:
10
10
        super(DiskUtilitiesTest, self).setUp()
11
11
        self.mount_file = self.makeFile("")
12
12
        self.stat_results = {}
13
 
        self.statvfs = self.stat_results.get
14
 
 
15
 
    def set_mount_points(self, points):
 
13
 
 
14
    def statvfs(self, point):
 
15
        """
 
16
        Return the requested mount point information. If C{read_access} was
 
17
        set to C{False} when this mount point was created, then we raise an
 
18
        exception to simulate a permission denied error.
 
19
        """
 
20
        if self.read_access:
 
21
            return self.stat_results[point]
 
22
        else:
 
23
            raise OSError("Permission denied")
 
24
 
 
25
    def set_mount_points(self, points, read_access=True):
 
26
        """
 
27
        This method prepares a fake mounts file containing the
 
28
        mount points specified in the C{points} list of strings. This file
 
29
        can then be used by referencing C{self.mount_file}.
 
30
 
 
31
        If C{read_access} is set to C{False}, then all mount points will
 
32
        yield a permission denied error when inspected.
 
33
        """
 
34
        self.read_access = read_access
16
35
        content = "\n".join("/dev/sda%d %s fsfs rw 0 0" % (i, point)
17
36
                            for i, point in enumerate(points))
18
37
        f = open(self.mount_file, "w")
59
78
        info = get_filesystem_for_path(
60
79
            "/", self.mount_file, self.statvfs, ["ext3", "fsfs"])
61
80
        self.assertNotIdentical(info, None)
 
81
 
 
82
    def test_ignore_unreadable_mount_point(self):
 
83
        """
 
84
        We should ignore mountpoints which are unreadable by the user who
 
85
        is logging in.
 
86
        """
 
87
        self.set_mount_points(["/secret"], read_access=False)
 
88
        info = get_filesystem_for_path(
 
89
            "/secret", self.mount_file, self.statvfs)
 
90
        self.assertIdentical(info, None)