예제 #1
0
파일: models.py 프로젝트: alrvivas/rh_campo
 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)
예제 #2
0
 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)
예제 #3
0
 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)
예제 #4
0
 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)
예제 #5
0
 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)
예제 #6
0
 def test_transforms_are_identified_in_headers(self):
     headers = ['foo']
     transforms = [('foo', 'http://www.%s.com')]
     got = get_transforms(headers, transforms)
     self.assertEqual([(0, 'http://www.%s.com')], got)
예제 #7
0
 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)
예제 #8
0
 def test_transforms_are_identified_in_headers(self):
     headers = ['foo']
     transforms = [('foo', 'http://www.%s.com')]
     got = get_transforms(headers, transforms)
     self.assertEqual([(0, 'http://www.%s.com')], got)