summaryrefslogtreecommitdiffstats
path: root/dbaccess/qa/python/fdo84315.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 05:54:39 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 05:54:39 +0000
commit267c6f2ac71f92999e969232431ba04678e7437e (patch)
tree358c9467650e1d0a1d7227a21dac2e3d08b622b2 /dbaccess/qa/python/fdo84315.py
parentInitial commit. (diff)
downloadlibreoffice-267c6f2ac71f92999e969232431ba04678e7437e.tar.xz
libreoffice-267c6f2ac71f92999e969232431ba04678e7437e.zip
Adding upstream version 4:24.2.0.upstream/4%24.2.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dbaccess/qa/python/fdo84315.py')
-rw-r--r--dbaccess/qa/python/fdo84315.py76
1 files changed, 76 insertions, 0 deletions
diff --git a/dbaccess/qa/python/fdo84315.py b/dbaccess/qa/python/fdo84315.py
new file mode 100644
index 0000000000..f58b16f513
--- /dev/null
+++ b/dbaccess/qa/python/fdo84315.py
@@ -0,0 +1,76 @@
+#! /usr/bin/env python
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+import os
+import unittest
+from collections import deque
+import unohelper
+from org.libreoffice.unotest import UnoInProcess
+
+class Fdo84315(unittest.TestCase):
+
+ @classmethod
+ def setUpClass(cls):
+ cls._uno = UnoInProcess()
+ cls._uno.setUp()
+ workdir = os.environ[ "WORKDIR_FOR_BUILD" ]
+ cls._xDoc = cls._uno.openDocFromAbsolutePath(workdir + "/CppunitTest/fdo84315.odb")
+
+ @classmethod
+ 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])
+ 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'])
+ 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])
+ xMeta = self.__test_Query('id', INTEGER, xResultset)
+ self.__test_ResultSetInteger(xResultset, expected_values)
+
+ xCon.dispose()
+
+if __name__ == '__main__':
+ unittest.main()