Example #1
0
 def test_summary_gets_built_for_multiple_cols(self):
     self.qr._headers = [ColumnHeader('a'), ColumnHeader('b')]
     self.qr._description = [("a", ), ("b", )]
     self.qr._data = [[1, 10], [2, 20]]
     self.qr.process()
     self.assertEqual(len([h for h in self.qr.headers if h.summary]), 2)
     self.assertEqual(self.qr.headers[0].summary.stats["Sum"], 3.0)
     self.assertEqual(self.qr.headers[1].summary.stats["Sum"], 30.0)
Example #2
0
 def test_get_headers_no_results(self):
     self.qr._description = None
     self.assertEqual([ColumnHeader('--')][0].title,
                      self.qr._get_headers()[0].title)
Example #3
0
 def test_multiple_transforms(self):
     self.qr._headers = [ColumnHeader('foo'), ColumnHeader('bar')]
     self.qr._data = [[1, 2]]
     self.qr.process()
     self.assertEqual(['<a href="1">1</a>', 'x: 2'], self.qr._data[0])
Example #4
0
 def test_transform_alters_row(self):
     self.qr._headers = [ColumnHeader('foo'), ColumnHeader('qux')]
     self.qr._data = [[1, 2]]
     self.qr.process()
     self.assertEqual(['<a href="1">1</a>', 2], self.qr._data[0])
Example #5
0
 def test_transforms_are_identified(self):
     self.qr._headers = [ColumnHeader('foo')]
     got = self.qr._get_transforms()
     self.assertEqual([(0, '<a href="{0}">{0}</a>')], got)
Example #6
0
 def test_uncode_with_nulls(self):
     self.qr._headers = [ColumnHeader('num'), ColumnHeader('char')]
     self.qr._description = [("num", ), ("char", )]
     self.qr._data = [[2, six.u("a")], [3, None]]
     self.qr.process()
     self.assertEqual(self.qr.data, [[2, b"a"], [3, None]])