def test_tooltip(self): ''' Tests if tooltips are built correctly ''' options_from_yaml = { 'headers': [{ 'text': 'Value A:', 'value': 'field_a' }, { 'text': 'Value B:', 'value': 'field_b' }] } self.assertEqual( BaseChart.build_tooltip(options_from_yaml), '<table>' '<tr style="text-align: left;">' '<th style="padding: 4px; padding-right: 10px;">Value A:</th>' '<td style="padding: 4px;">@field_a</td>' '</tr>' '<tr style="text-align: left;">' '<th style="padding: 4px; padding-right: 10px;">Value B:</th>' '<td style="padding: 4px;">@field_b</td>' '</tr>' '</table>')
def test_tooltip_no_headers(self): ''' Tests if default tooltip is returned when no headers are given ''' self.assertEqual(BaseChart.build_tooltip({}), 'Tooltip!')
def test_tooltip_no_option(self): ''' Tests if default tooltip is returned when no option is given ''' self.assertEqual(BaseChart.build_tooltip(None), 'Tooltip!')