예제 #1
0
    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')
예제 #2
0
    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')
예제 #3
0
def setup_table(options, fmt=None):
    """
    Return a TextTable already setup based on display command line options like
    color and header.
    """
    tbl = TextTable(fmt)
    tbl.color = (options.color == 'auto' and Globals()['color'] == 'auto' \
                      and sys.stdout.isatty()) or \
                (options.color == 'auto' and Globals()['color'] == 'always') \
                or (options.color == 'always')

    tbl.show_header = options.header
    return tbl
예제 #4
0
def setup_table(options, fmt=None):
    """
    Return a TextTable already setup based on display command line options like
    color and header.
    """
    tbl = TextTable(fmt)
    tbl.color = (options.color == 'auto' and Globals()['color'] == 'auto' \
                      and sys.stdout.isatty()) or \
                (options.color == 'auto' and Globals()['color'] == 'always') \
                or (options.color == 'always')

    tbl.show_header = options.header
    return tbl
예제 #5
0
 def test_noheader(self):
     """output without header"""
     tbl = TextTable("%one")
     tbl.show_header = False
     tbl.append({'one': 'foo'})
     self.assertEqual(str(tbl), "foo")
예제 #6
0
 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')
예제 #7
0
 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')
예제 #8
0
 def _fmt_str(self, fmt, txt):
     tbl = TextTable(fmt)
     tbl.show_header = False
     table_fill(tbl, self._fs)
     self.assertEqual(str(tbl), txt)
예제 #9
0
파일: DisplayTest.py 프로젝트: thiell/shine
 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')
예제 #10
0
파일: DisplayTest.py 프로젝트: thiell/shine
 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')
예제 #11
0
파일: DisplayTest.py 프로젝트: thiell/shine
 def _fmt_str(self, fmt, txt):
     tbl = TextTable(fmt)
     tbl.show_header = False
     table_fill(tbl, self._fs)
     self.assertEqual(str(tbl), txt)
예제 #12
0
 def test_padding_noheader(self):
     """ignore header labels for padding when disabled"""
     tbl = TextTable("%longer %foo")
     tbl.show_header = False
     tbl.append({'longer': 'short', 'foo': 'data'})
     self.assertEqual(str(tbl), 'short data')
예제 #13
0
 def test_noheader(self):
     """output without header"""
     tbl = TextTable("%one")
     tbl.show_header = False
     tbl.append({'one': 'foo'})
     self.assertEqual(str(tbl), "foo")