Ejemplo n.º 1
0
 def test2_check_mounpoint_type(self):
     """
     Check object type of returned filesystems
     """
     try:
         mp = MountPoints()
     except FileSystemError, emsg:
         print emsg
         return
Ejemplo n.º 2
0
 def test1_list_mountpoints(self):
     """
     Test listing mount points on this platform
     """
     try:
         mp = MountPoints()
         self.assertIsInstance(mp.keys(), list)
     except FileSystemError, emsg:
         print emsg
         return
def test_mountpoint_sorting(platform_mock_binaries):
    """Test sorting of mountpoints

    """
    from systematic.filesystems import MountPoints
    mounts = MountPoints()

    values = sorted(mp for mp in mounts)
    assert len(values) == len(mounts)

    mounts.sort()
    for i, mp in enumerate(mounts):
        assert mp == values[i]
def test_mountpoint_attributes(platform_mock_binaries):
    """Test mountpoint attributes

    """

    from systematic.filesystems import MountPoints
    from systematic.classes import MountPoint

    mounts = MountPoints()
    assert len(mounts) > 0

    for mp in mounts:
        assert isinstance(mp, MountPoint)

        assert isinstance(mp.path, str)
        assert isinstance(mp.name, str)

        assert isinstance(mp.usage, dict)
        assert isinstance(mp.flags, dict)

        assert isinstance(mp.size, int)
        assert isinstance(mp.used, int)
        assert isinstance(mp.available, int)
        assert isinstance(mp.free, int)
        assert isinstance(mp.percent, int)

        assert isinstance(mp.as_dict(), dict)
        json.dumps(mp.as_dict())

        # Only available with MacOS (darwin) ps output
        if hasattr(mp, 'blocksize'):
            assert isinstance(mp.blocksize, int)
        for attr in ('internal', 'writable', 'bootable', 'ejectable',
                     'removable'):
            if hasattr(mp, attr):
                assert isinstance(getattr(mp, attr), bool)
Ejemplo n.º 5
0
 def __init__(self):
     super(MountpointStats, self).__init__()
     self.mountpoints = MountPoints()
     self.update_timestamp()