本文整理汇总了Python中pbcommand.models.report.Report.add_table方法的典型用法代码示例。如果您正苦于以下问题:Python Report.add_table方法的具体用法?Python Report.add_table怎么用?Python Report.add_table使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pbcommand.models.report.Report
的用法示例。
在下文中一共展示了Report.add_table方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_to_dict_multi
# 需要导入模块: from pbcommand.models.report import Report [as 别名]
# 或者: from pbcommand.models.report.Report import add_table [as 别名]
def test_to_dict_multi(self):
"""
Multiple complex elements.
The id of report sub elements is prepended with the id of the parent
element when to_dict is called.
"""
r = Report('redfang')
a = Attribute('a', 'b')
a2 = Attribute('a2', 'b2')
r.add_attribute(a)
r.add_attribute(a2)
pg = PlotGroup('pgid')
pg.add_plot(Plot('pid', 'anImg'))
pg.add_plot(Plot('pid2', 'anImg2'))
r.add_plotgroup(pg)
pg = PlotGroup('pgid2')
pg.add_plot(Plot('pid2', 'anImg2'))
pg.add_plot(Plot('pid22', 'anImg22'))
r.add_plotgroup(pg)
t = Table('tabid')
t.add_column(Column('c1'))
r.add_table(t)
t = Table('tabid2')
t.add_column(Column('c2'))
r.add_table(t)
d = r.to_dict()
log.debug(str(d))
self.assertEqual('redfang', d['id'])
self.assertEqual('redfang.a', d['attributes'][0]['id'])
self.assertEqual('redfang.a2', d['attributes'][1]['id'])
self.assertEqual('redfang.pgid', d['plotGroups'][0]['id'])
self.assertEqual('redfang.pgid.pid', d[
'plotGroups'][0]['plots'][0]['id'])
self.assertEqual('redfang.pgid.pid2', d[
'plotGroups'][0]['plots'][1]['id'])
self.assertEqual('redfang.pgid2', d['plotGroups'][1]['id'])
self.assertEqual('redfang.pgid2.pid2', d[
'plotGroups'][1]['plots'][0]['id'])
self.assertEqual('redfang.pgid2.pid22', d[
'plotGroups'][1]['plots'][1]['id'])
self.assertEqual('redfang.tabid', d['tables'][0]['id'])
self.assertEqual('redfang.tabid.c1', d['tables'][
0]['columns'][0]['id'])
self.assertEqual('redfang.tabid2', d['tables'][1]['id'])
self.assertEqual('redfang.tabid2.c2', d[
'tables'][1]['columns'][0]['id'])
log.info(repr(r))
self.assertIsNotNone(repr(r))
示例2: test_to_dict
# 需要导入模块: from pbcommand.models.report import Report [as 别名]
# 或者: from pbcommand.models.report.Report import add_table [as 别名]
def test_to_dict(self):
"""
The id of report sub elements is prepended with the id of the parent
element when to_dict is called.
"""
r = Report('redfang')
a = Attribute('a', 'b')
a2 = Attribute('a2', 'b2')
r.add_attribute(a)
r.add_attribute(a2)
pg = PlotGroup('pgid')
pg.add_plot(Plot('pid', 'anImg'))
pg.add_plot(Plot('pid2', 'anImg2'))
r.add_plotgroup(pg)
t = Table('tabid')
t.add_column(Column('c1'))
r.add_table(t)
d = r.to_dict()
log.debug("\n" + pformat(d))
self.assertEqual('redfang', d['id'])
self.assertEqual('redfang.a', d['attributes'][0]['id'])
self.assertEqual('redfang.a2', d['attributes'][1]['id'])
self.assertEqual('redfang.pgid', d['plotGroups'][0]['id'])
self.assertEqual('redfang.pgid.pid', d['plotGroups'][0]['plots'][0]['id'])
self.assertEqual('redfang.pgid.pid2', d['plotGroups'][0]['plots'][1]['id'])
self.assertEqual('redfang.tabid', d['tables'][0]['id'])
self.assertEqual('redfang.tabid.c1', d['tables'][0]['columns'][0]['id'])
示例3: test_get_table_by_id_with_bad_id
# 需要导入模块: from pbcommand.models.report import Report [as 别名]
# 或者: from pbcommand.models.report.Report import add_table [as 别名]
def test_get_table_by_id_with_bad_id(self):
r = Report('redfang')
t1 = Table('tabid1')
t1.add_column(Column('c1'))
r.add_table(t1)
bad_t = r.get_table_by_id('id_that_does_not_exist')
self.assertIsNone(bad_t)
示例4: test_get_table_by_id
# 需要导入模块: from pbcommand.models.report import Report [as 别名]
# 或者: from pbcommand.models.report.Report import add_table [as 别名]
def test_get_table_by_id(self):
r = Report('redfang')
t1 = Table('tabid1')
t1.add_column(Column('c1'))
r.add_table(t1)
t = r.get_table_by_id('tabid1')
self.assertEqual(t, t1)
示例5: test_get_column_by_id
# 需要导入模块: from pbcommand.models.report import Report [as 别名]
# 或者: from pbcommand.models.report.Report import add_table [as 别名]
def test_get_column_by_id(self):
r = Report('redfang')
t1 = Table('tabid1')
c1 = Column('c1')
t1.add_column(c1)
r.add_table(t1)
c = r.get_table_by_id('tabid1').get_column_by_id('c1')
self.assertEqual(c, c1)
示例6: test_to_dict_multi
# 需要导入模块: from pbcommand.models.report import Report [as 别名]
# 或者: from pbcommand.models.report.Report import add_table [as 别名]
def test_to_dict_multi(self):
"""
Multiple complex elements.
The id of report sub elements is prepended with the id of the parent
element when to_dict is called.
"""
r = Report("redfang")
a = Attribute("a", "b")
a2 = Attribute("a2", "b2")
r.add_attribute(a)
r.add_attribute(a2)
pg = PlotGroup("pgid")
pg.add_plot(Plot("pid", "anImg"))
pg.add_plot(Plot("pid2", "anImg2"))
r.add_plotgroup(pg)
pg = PlotGroup("pgid2")
pg.add_plot(Plot("pid2", "anImg2"))
pg.add_plot(Plot("pid22", "anImg22"))
r.add_plotgroup(pg)
t = Table("tabid")
t.add_column(Column("c1"))
r.add_table(t)
t = Table("tabid2")
t.add_column(Column("c2"))
r.add_table(t)
d = r.to_dict()
log.debug(str(d))
self.assertEqual("redfang", d["id"])
self.assertEqual("redfang.a", d["attributes"][0]["id"])
self.assertEqual("redfang.a2", d["attributes"][1]["id"])
self.assertEqual("redfang.pgid", d["plotGroups"][0]["id"])
self.assertEqual("redfang.pgid.pid", d["plotGroups"][0]["plots"][0]["id"])
self.assertEqual("redfang.pgid.pid2", d["plotGroups"][0]["plots"][1]["id"])
self.assertEqual("redfang.pgid2", d["plotGroups"][1]["id"])
self.assertEqual("redfang.pgid2.pid2", d["plotGroups"][1]["plots"][0]["id"])
self.assertEqual("redfang.pgid2.pid22", d["plotGroups"][1]["plots"][1]["id"])
self.assertEqual("redfang.tabid", d["tables"][0]["id"])
self.assertEqual("redfang.tabid.c1", d["tables"][0]["columns"][0]["id"])
self.assertEqual("redfang.tabid2", d["tables"][1]["id"])
self.assertEqual("redfang.tabid2.c2", d["tables"][1]["columns"][0]["id"])
log.info(repr(r))
self.assertIsNotNone(repr(r))