def _execute(self): cursor, duration = execute_query(self.final_sql()) headers = [d[0] for d in cursor.description] if cursor.description else ['--'] transforms = get_transforms(headers, app_settings.EXPLORER_TRANSFORMS) return QueryResult(headers=headers, data=[transform_row(transforms, r) for r in cursor.fetchall()], duration=duration, error=None)
def test_multiple_transforms(self): headers = ['foo', 'bar'] transforms = get_transforms(headers, [('foo', '<a href="{0}">{0}</a>'), ('bar', 'x: {0}')]) rows = [[1, 2], ['a', 'b']] got = [transform_row(transforms, row) for row in rows] expected = [['<a href="1">1</a>', 'x: 2'], ['<a href="a">a</a>', 'x: b']] self.assertEqual(expected, got)
def _execute(self): cursor, duration = execute_query(self.final_sql()) headers = [d[0] for d in cursor.description ] if cursor.description else ['--'] transforms = get_transforms(headers, app_settings.EXPLORER_TRANSFORMS) return QueryResult( headers=headers, data=[transform_row(transforms, r) for r in cursor.fetchall()], duration=duration, error=None)
def test_multiple_transforms(self): headers = ['foo', 'bar'] transforms = get_transforms(headers, [('foo', '<a href="{0}">{0}</a>'), ('bar', 'x: {0}')]) rows = [[1, 2], ['a', 'b']] got = [transform_row(transforms, row) for row in rows] expected = [ ['<a href="1">1</a>', 'x: 2'], ['<a href="a">a</a>', 'x: b'] ] self.assertEqual(expected, got)
def test_transform_alters_row(self): headers = ['foo', 'bar'] transforms = get_transforms(headers, [('bar', 'http://www.{0}.com')]) row = [1, 2] got = transform_row(transforms, row) self.assertEqual([1, 'http://www.2.com'], got)