| 1 | import logging |
| 2 | |
| 3 | import pytest |
| 4 | |
| 5 | from pbcommand.models.report import Column |
| 6 | |
| 7 | log = logging.getLogger(__name__) |
| 8 | |
| 9 | |
| 10 | class TestColumn: |
| 11 | |
| 12 | def test_column(self): |
| 13 | """Test: Can't create a Column without an id.""" |
| 14 | def none_col(): |
| 15 | c = Column(None) |
| 16 | |
| 17 | with pytest.raises(Exception): |
| 18 | none_col() |
| 19 | |
| 20 | def test_repr(self): |
| 21 | c = Column('my_column', header="My Column", values=list(range(5))) |
| 22 | assert repr(c) is not None |
| 23 | |
| 24 | # def test_plotgroup_add_duplicate_plot(self): |
| 25 | # ''' |
| 26 | # Test: Can't add plots with duplicate ids |
| 27 | # ''' |
| 28 | # try: |
| 29 | # log.info( TestPlotGroup.test_plotgroup_add_duplicate_plot.__doc__ ) |
| 30 | # pg = PlotGroup('foo') |
| 31 | # pg.add_plot(Plot('id', 'i1')) |
| 32 | # |
| 33 | # try: |
| 34 | # pg.add_plot( Plot('id', 'i2') ) |
| 35 | # self.fail( 'Cannot add plot with same id' ) |
| 36 | # except PbReportError: |
| 37 | # pass |
| 38 | # except: |
| 39 | # log.error(traceback.format_exc()) |
| 40 | # raise |
| 41 | # |
| 42 | # |
| 43 | # |
| 44 | # def test_plotgroup_id_prepend(self): |
| 45 | # ''' |
| 46 | # Test: PlotGroup id gets prepended to plot.id when plot is added |
| 47 | # ''' |
| 48 | # try: |
| 49 | # log.info( TestPlotGroup.test_plotgroup_id_prepend.__doc__ ) |
| 50 | # pg = PlotGroup('foo') |
| 51 | # pg.add_plot( Plot('id', 'i1') ) |
| 52 | # assert 'foo.id' == pg.plots[0].id |
| 53 | # except: |
| 54 | # log.error(traceback.format_exc()) |
| 55 | # raise |
| 56 | # |
| 57 | # |
| 58 | # def test_to_dict(self): |
| 59 | # ''' |
| 60 | # Test plotGroup to_dict function |
| 61 | # ''' |
| 62 | # try: |
| 63 | # log.info( TestPlotGroup.test_to_dict.__doc__ ) |
| 64 | # a = PlotGroup(123, 'foo title', 'foo legend', 'foo thumbnail' ) |
| 65 | # a.add_plot( Plot('id', 'i1') ) |
| 66 | # |
| 67 | # d = a.to_dict() |
| 68 | # assert 123 == d['id'] |
| 69 | # assert 'foo title' == d['title'] |
| 70 | # assert 'foo legend' == d['legend'] |
| 71 | # assert 'foo thumbnail' == d['thumbnail'] |
| 72 | # assert 1 == len(d['plots']) |
| 73 | # except: |
| 74 | # log.error(traceback.format_exc()) |
| 75 | # raise |
| 76 | # |
| 77 | # |
| 78 | # |