def test_sorting(self): """fill with 2 different sortings""" tbl = TextTable(fmt="%4fsname %node") tbl.show_header = False key = lambda t: t.TYPE table_fill(tbl, self._fs, key) self.assertEqual(str(tbl), 'c... foo2\nc... foo1\nc... foo3\nc... foo0') tbl = TextTable(fmt="%4fsname %node") tbl.show_header = False key = lambda t: t.DISPLAY_ORDER table_fill(tbl, self._fs, key) self.assertEqual(str(tbl), 'c... foo0\nc... foo1\nc... foo2\nc... foo3')
def test_support(self): """fill with a support filter""" tbl = TextTable(fmt="%3type %node %count") tbl.show_header = False table_fill(tbl, self._fs, None, supports='dev') self.assertEqual(str(tbl), 'MGT foo1 1\nMDT foo2 1\nOST foo3 2')
def test_format_group(self): """fill with group field in format""" tbl = TextTable(fmt="%3type %count") tbl.show_header = False table_fill(tbl, self._fs) self.assertEqual(str(tbl), 'MDT 1\nMGT 1\nOST 2\nROU 1')
def test_empty_fs(self): """fill with an empty filesystem""" tbl = TextTable() table_fill(tbl, self._fs, None) self.assertEqual(len(tbl), 0)
def _fmt_str(self, fmt, txt): tbl = TextTable(fmt) tbl.show_header = False table_fill(tbl, self._fs) self.assertEqual(str(tbl), txt)