[Libreoffice-commits] core.git: dbaccess/qa
slideon
adamkasztenny at gmail.com
Mon Apr 4 06:40:07 UTC 2016
dbaccess/qa/python/fdo84315.py | 58 ++++++++++++++++++++---------------------
1 file changed, 29 insertions(+), 29 deletions(-)
New commits:
commit 9338e4f5b1ffcba2d5b0bd8960dd8795d8909ff1
Author: slideon <adamkasztenny at gmail.com>
Date: Fri Apr 1 09:51:57 2016 -0400
tdf#97361 Refactor dbaccess test again
Remove duplicate code, add helper functions and constants
Change-Id: Ib8702e2ce9918b47a608f6eb6fd2af7fd4dd1d0d
Reviewed-on: https://gerrit.libreoffice.org/23727
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: jan iversen <jani at documentfoundation.org>
diff --git a/dbaccess/qa/python/fdo84315.py b/dbaccess/qa/python/fdo84315.py
index a4bbc1b..03acc0a 100644
--- a/dbaccess/qa/python/fdo84315.py
+++ b/dbaccess/qa/python/fdo84315.py
@@ -14,8 +14,6 @@ import unohelper
from org.libreoffice.unotest import UnoInProcess
class Fdo84315(unittest.TestCase):
- _uno = None
- _xDoc = None
@classmethod
def setUpClass(cls):
@@ -28,47 +26,49 @@ class Fdo84315(unittest.TestCase):
def tearDownClass(cls):
cls._uno.tearDown()
+ def __test_Query(self, column_name, expected_type, xResultset):
+ self.assertTrue(xResultset)
+ xMeta = xResultset.MetaData
+ self.assertEqual(xMeta.ColumnCount, 1)
+ self.assertEqual(xResultset.findColumn(column_name), 1)
+ self.assertEqual(xMeta.getColumnName(1), column_name)
+ self.assertEqual(xMeta.getColumnType(1), expected_type)
+ return xMeta
+
+ def __test_ResultSetInteger(self, xResultset, expected_values):
+ while xResultset.next():
+ self.assertEqual(xResultset.getInt(1), expected_values.popleft())
+ self.assertEqual(len(expected_values), 0)
+
+ def __test_ResultSetString(self, xResultset, expected_values):
+ while xResultset.next():
+ self.assertEqual(xResultset.getString(1), expected_values.popleft())
+ self.assertEqual(len(expected_values), 0)
+
def test_fdo84315(self):
xDoc = self.__class__._xDoc
xDataSource = xDoc.DataSource
xCon = xDataSource.getConnection('','')
xStatement = xCon.createStatement()
+ NUMERIC = 2
+ VAR_CHAR = 12
+ INTEGER = 4
+
xResultset = xStatement.executeQuery('SELECT "count" FROM "test_table"')
expected_values = deque([42, 4711])
- self.assertTrue(xResultset)
- xMeta = xResultset.MetaData
- self.assertEqual(xMeta.ColumnCount, 1)
- self.assertEqual(xResultset.findColumn("count"), 1)
- self.assertEqual(xMeta.getColumnName(1), "count");
- self.assertEqual(xMeta.getColumnType(1), 2); # numeric
- while xResultset.next():
- self.assertEqual(xResultset.getInt(1), expected_values.popleft())
- self.assertEqual(len(expected_values), 0)
+ xMeta = self.__test_Query('count', NUMERIC, xResultset)
+ self.__test_ResultSetInteger(xResultset, expected_values)
xResultset = xStatement.executeQuery('SELECT "name" FROM "test_table"')
expected_values = deque(['foo', 'bar'])
- self.assertTrue(xResultset)
- xMeta = xResultset.MetaData
- self.assertEqual(xMeta.ColumnCount, 1)
- self.assertEqual(xResultset.findColumn("name"), 1)
- self.assertEqual(xMeta.getColumnName(1), "name");
- self.assertEqual(xMeta.getColumnType(1), 12); # varchar
- while xResultset.next():
- self.assertEqual(xResultset.getString(1), expected_values.popleft())
- self.assertEqual(len(expected_values), 0)
+ xMeta = self.__test_Query('name', VAR_CHAR, xResultset)
+ self.__test_ResultSetString(xResultset, expected_values)
xResultset = xStatement.executeQuery('SELECT "id" FROM "test_table"')
expected_values = deque([0, 1])
- self.assertTrue(xResultset)
- xMeta = xResultset.MetaData
- self.assertEqual(xMeta.ColumnCount, 1)
- self.assertEqual(xResultset.findColumn("id"), 1)
- self.assertEqual(xMeta.getColumnName(1), "id");
- self.assertEqual(xMeta.getColumnType(1), 4); # integer
- while xResultset.next():
- self.assertEqual(xResultset.getInt(1), expected_values.popleft())
- self.assertEqual(len(expected_values), 0)
+ xMeta = self.__test_Query('id', INTEGER, xResultset)
+ self.__test_ResultSetInteger(xResultset, expected_values)
xCon.dispose()
More information about the Libreoffice-commits
mailing list