tdf#130857 qt weld: Implement QtInstanceWidget::get_text_height
[LibreOffice.git] / dbaccess / qa / python / fdo84315.py
blob75954c0cd0b2fe30817f2c0037e8db873aa5bda6
1 #! /usr/bin/env python
3 # This file is part of the LibreOffice project.
5 # This Source Code Form is subject to the terms of the Mozilla Public
6 # License, v. 2.0. If a copy of the MPL was not distributed with this
7 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 import os
11 import unittest
12 from collections import deque
13 from org.libreoffice.unotest import UnoInProcess
15 class Fdo84315(unittest.TestCase):
17 @classmethod
18 def setUpClass(cls):
19 cls._uno = UnoInProcess()
20 cls._uno.setUp()
21 workdir = os.environ[ "WORKDIR_FOR_BUILD" ]
22 cls._xDoc = cls._uno.openDocFromAbsolutePath(workdir + "/CppunitTest/fdo84315.odb")
24 @classmethod
25 def tearDownClass(cls):
26 cls._uno.tearDown()
28 def __test_Query(self, column_name, expected_type, xResultset):
29 self.assertTrue(xResultset)
30 xMeta = xResultset.MetaData
31 self.assertEqual(xMeta.ColumnCount, 1)
32 self.assertEqual(xResultset.findColumn(column_name), 1)
33 self.assertEqual(xMeta.getColumnName(1), column_name)
34 self.assertEqual(xMeta.getColumnType(1), expected_type)
35 return xMeta
37 def __test_ResultSetInteger(self, xResultset, expected_values):
38 while xResultset.next():
39 self.assertEqual(xResultset.getInt(1), expected_values.popleft())
40 self.assertEqual(len(expected_values), 0)
42 def __test_ResultSetString(self, xResultset, expected_values):
43 while xResultset.next():
44 self.assertEqual(xResultset.getString(1), expected_values.popleft())
45 self.assertEqual(len(expected_values), 0)
47 def test_fdo84315(self):
48 xDoc = self.__class__._xDoc
49 xDataSource = xDoc.DataSource
50 xCon = xDataSource.getConnection('','')
51 xStatement = xCon.createStatement()
53 NUMERIC = 2
54 VAR_CHAR = 12
55 INTEGER = 4
57 xResultset = xStatement.executeQuery('SELECT "count" FROM "test_table"')
58 expected_values = deque([42, 4711])
59 self.__test_Query('count', NUMERIC, xResultset)
60 self.__test_ResultSetInteger(xResultset, expected_values)
62 xResultset = xStatement.executeQuery('SELECT "name" FROM "test_table"')
63 expected_values = deque(['foo', 'bar'])
64 self.__test_Query('name', VAR_CHAR, xResultset)
65 self.__test_ResultSetString(xResultset, expected_values)
67 xResultset = xStatement.executeQuery('SELECT "id" FROM "test_table"')
68 expected_values = deque([0, 1])
69 self.__test_Query('id', INTEGER, xResultset)
70 self.__test_ResultSetInteger(xResultset, expected_values)
72 xCon.dispose()
74 if __name__ == '__main__':
75 unittest.main()