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/.
12 from collections
import deque
14 from org
.libreoffice
.unotest
import UnoInProcess
16 class Fdo84315(unittest
.TestCase
):
22 cls
._uno
= UnoInProcess()
24 workdir
= os
.environ
[ "WORKDIR_FOR_BUILD" ]
25 cls
._xDoc
= cls
._uno
.openDoc(workdir
+ "/CppunitTest/fdo84315.odb")
28 def tearDownClass(cls
):
31 def test_fdo84315(self
):
32 xDoc
= self
.__class
__._xDoc
33 xDataSource
= xDoc
.DataSource
34 xCon
= xDataSource
.getConnection('','')
35 xStatement
= xCon
.createStatement()
37 xResultset
= xStatement
.executeQuery('SELECT "count" FROM "test_table"')
38 expected_values
= deque([42, 4711])
39 self
.assertTrue(xResultset
)
40 xMeta
= xResultset
.MetaData
41 self
.assertEqual(xMeta
.ColumnCount
, 1)
42 self
.assertEqual(xResultset
.findColumn("count"), 1)
43 self
.assertEqual(xMeta
.getColumnName(1), "count");
44 self
.assertEqual(xMeta
.getColumnType(1), 2); # numeric
45 while xResultset
.next():
46 self
.assertEqual(xResultset
.getInt(1), expected_values
.popleft())
47 self
.assertEqual(len(expected_values
), 0)
49 xResultset
= xStatement
.executeQuery('SELECT "name" FROM "test_table"')
50 expected_values
= deque(['foo', 'bar'])
51 self
.assertTrue(xResultset
)
52 xMeta
= xResultset
.MetaData
53 self
.assertEqual(xMeta
.ColumnCount
, 1)
54 self
.assertEqual(xResultset
.findColumn("name"), 1)
55 self
.assertEqual(xMeta
.getColumnName(1), "name");
56 self
.assertEqual(xMeta
.getColumnType(1), 12); # varchar
57 while xResultset
.next():
58 self
.assertEqual(xResultset
.getString(1), expected_values
.popleft())
59 self
.assertEqual(len(expected_values
), 0)
61 xResultset
= xStatement
.executeQuery('SELECT "id" FROM "test_table"')
62 expected_values
= deque([0, 1])
63 self
.assertTrue(xResultset
)
64 xMeta
= xResultset
.MetaData
65 self
.assertEqual(xMeta
.ColumnCount
, 1)
66 self
.assertEqual(xResultset
.findColumn("id"), 1)
67 self
.assertEqual(xMeta
.getColumnName(1), "id");
68 self
.assertEqual(xMeta
.getColumnType(1), 4); # integer
69 while xResultset
.next():
70 self
.assertEqual(xResultset
.getInt(1), expected_values
.popleft())
71 self
.assertEqual(len(expected_values
), 0)
75 if __name__
== '__main__':