本文整理汇总了Python中pbcommand.models.report.Table.to_dict方法的典型用法代码示例。如果您正苦于以下问题:Python Table.to_dict方法的具体用法?Python Table.to_dict怎么用?Python Table.to_dict使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pbcommand.models.report.Table
的用法示例。
在下文中一共展示了Table.to_dict方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestBasicTable
# 需要导入模块: from pbcommand.models.report import Table [as 别名]
# 或者: from pbcommand.models.report.Table import to_dict [as 别名]
class TestBasicTable(unittest.TestCase):
"""Basic Smoke tests"""
def setUp(self):
self.columns = [Column('one', header="One"),
Column('two', header="Two"),
Column('three', header="Three")]
self.table = Table('my_table_with_values', columns=self.columns)
datum = {'one': list(xrange(3)), 'two': list('abc'),
'three': 'file1 file2 file3'.split()}
for k, values in datum.iteritems():
for value in values:
self.table.add_data_by_column_id(k, value)
def test_str(self):
"""Smoke test for conversion to str"""
log.info(str(self.table))
self.assertIsNotNone(str(self.table))
def test_columns(self):
"""Test Columns"""
self.assertEqual(len(self.table.columns), 3)
def test_column_values(self):
"""Basic check for column values"""
for column in self.table.columns:
self.assertEqual(len(column.values), 3)
def test_to_dict(self):
"""Conversion to dictionary"""
self.assertTrue(isinstance(self.table.to_dict(), dict))
log.info(self.table.to_dict())
示例2: TestEmptyTable
# 需要导入模块: from pbcommand.models.report import Table [as 别名]
# 或者: from pbcommand.models.report.Table import to_dict [as 别名]
class TestEmptyTable(unittest.TestCase):
"""Basic Smoke tests"""
def setUp(self):
self.columns = [Column('one', header="One"),
Column('two', header="Two"),
Column('three', header="Three")]
self.table = Table('my_table', columns=self.columns)
def test_str(self):
"""Smoke test for conversion to str"""
log.info(str(self.table))
self.assertIsNotNone(str(self.table))
def test_columns(self):
"""Test Columns"""
self.assertEqual(len(self.table.columns), 3)
def test_column_values(self):
"""Basic check for column values"""
for column in self.table.columns:
self.assertEqual(len(column.values), 0)
def test_to_dict(self):
"""Conversion to dictionary"""
self.assertTrue(isinstance(self.table.to_dict(), dict))
log.info(self.table.to_dict())
示例3: test_basic
# 需要导入模块: from pbcommand.models.report import Table [as 别名]
# 或者: from pbcommand.models.report.Table import to_dict [as 别名]
def test_basic(self):
n = 3
columns = [_column_generator("my_id1", list(xrange(n))), _column_generator("my_id2", string.lowercase[:n])]
title = "My Table"
table = Table("my_table", title=title, columns=columns)
d = table.to_dict()
validate_table(d)
self.assertIsNotNone(d)