diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 16:51:28 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 16:51:28 +0000 |
commit | 940b4d1848e8c70ab7642901a68594e8016caffc (patch) | |
tree | eb72f344ee6c3d9b80a7ecc079ea79e9fba8676d /dbaccess/qa/python/fdo84315.py | |
parent | Initial commit. (diff) | |
download | libreoffice-940b4d1848e8c70ab7642901a68594e8016caffc.tar.xz libreoffice-940b4d1848e8c70ab7642901a68594e8016caffc.zip |
Adding upstream version 1:7.0.4.upstream/1%7.0.4upstream
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.py | 76 |
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 000000000..f58b16f51 --- /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() |