Example #1
0
    def test_set_empty(self):
        # This test also has the side-effect of testing that we're handling
        # empty vector results correctly.

        statgrab.set_valid_filesystems([])
        self.assertEqual(statgrab.get_valid_filesystems(), [])

        # If we set the list of valid filesystems to be empty, we shouldn't get
        # any filesystem results.
        self.assertEqual(len(statgrab.get_fs_stats()), 0)
Example #2
0
    def test_set_empty(self):
        # This test also has the side-effect of testing that we're handling
        # empty vector results correctly.

        statgrab.set_valid_filesystems([])
        self.assertEqual(statgrab.get_valid_filesystems(), [])

        # If we set the list of valid filesystems to be empty, we shouldn't get
        # any filesystem results.
        self.assertEqual(len(statgrab.get_fs_stats()), 0)
Example #3
0
    def test_set_real(self):
        # Try to filter out some real filesystems.
        stats1 = statgrab.get_fs_stats()
        types = [st.fs_type for st in stats1]

        if len(types) < 2:
            # We have... 0 or 1 types of filesystem currently mounted?
            # Weird but possible, so just give up on this test.
            return

        # Try limiting results to just the first type.
        first = types[0]
        statgrab.set_valid_filesystems([first])

        stats2 = statgrab.get_fs_stats()
        self.assertTrue(len(stats2) < len(stats1))
        for st in stats2:
            self.assertEqual(st.fs_type, first)
Example #4
0
    def test_set_real(self):
        # Try to filter out some real filesystems.
        stats1 = statgrab.get_fs_stats()
        types = [st.fs_type for st in stats1]

        if len(types) < 2:
            # We have... 0 or 1 types of filesystem currently mounted?
            # Weird but possible, so just give up on this test.
            return

        # Try limiting results to just the first type.
        first = types[0]
        statgrab.set_valid_filesystems([first])

        stats2 = statgrab.get_fs_stats()
        self.assertTrue(len(stats2) < len(stats1))
        for st in stats2:
            self.assertEqual(st.fs_type, first)
Example #5
0
 def test_set_new(self):
     vfs1 = ["ext4", "notarealfs", "isofs"]
     statgrab.set_valid_filesystems(vfs1)
     vfs2 = statgrab.get_valid_filesystems()
     # The order can differ but the contents should be the same.
     self.assertEqual(sorted(vfs1), sorted(vfs2))
Example #6
0
 def test_set_existing(self):
     vfs1 = statgrab.get_valid_filesystems()
     statgrab.set_valid_filesystems(vfs1)
     vfs2 = statgrab.get_valid_filesystems()
     # The order can differ but the contents should be the same.
     self.assertEqual(sorted(vfs1), sorted(vfs2))
Example #7
0
 def test_set_new(self):
     vfs1 = ["ext4", "notarealfs", "isofs"]
     statgrab.set_valid_filesystems(vfs1)
     vfs2 = statgrab.get_valid_filesystems()
     # The order can differ but the contents should be the same.
     self.assertEqual(sorted(vfs1), sorted(vfs2))
Example #8
0
 def test_set_existing(self):
     vfs1 = statgrab.get_valid_filesystems()
     statgrab.set_valid_filesystems(vfs1)
     vfs2 = statgrab.get_valid_filesystems()
     # The order can differ but the contents should be the same.
     self.assertEqual(sorted(vfs1), sorted(vfs2))