test creation and str-formatting of FilesystemFillState since I once stumbled over...
authorChristian Herdtweck <christian.herdtweck@intra2net.com>
Wed, 13 Jan 2016 16:12:48 +0000 (17:12 +0100)
committerChristian Herdtweck <christian.herdtweck@intra2net.com>
Wed, 13 Jan 2016 16:12:48 +0000 (17:12 +0100)
test/file_helper_unittest.py

index 7dbdb3f..804d829 100644 (file)
@@ -31,6 +31,24 @@ class FileHelperTester(unittest.TestCase):
         self.assertEqual(os.getcwd(), start_cwd)
 
 
+    def test_obj_str(self):
+        """ test FilesystemFillState.__str__ """
+
+        # create dummy state
+        GIGABYTE = 2**30
+        state = file_helpers.FilesystemFillState()
+        state.name = 'dummy'
+        state.size = 10 * GIGABYTE
+        state.used = 9 * GIGABYTE
+        state.available = 1 * GIGABYTE
+        state.capacity = 90
+        state.mount_point = '/not/mounted'
+
+        expect = '[Filesystem {0} mounted at {1}: {2}% used]' \
+                 .format(state.name, state.mount_point, state.capacity)
+
+        self.assertEqual(str(state), expect)
+
     def test_disc_stats(self):
         """ tests get_filesystem_fill_states """