OmniSciDB
a5dc49c757
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
test_cursor.py
Go to the documentation of this file.
1
import
pytest
2
from
heavydb.cursor
import
Cursor, _bind_parameters
3
from
heavydb
import
connect
4
5
6
@pytest.fixture
7
def
mock_connection
(mock_client):
8
"""Connection with mocked transport layer, and
9
10
- username='user'
11
- password='password'
12
- host='localhost'
13
- dbname='dbname'
14
"""
15
return
connect
(
16
user=
'user'
, password=
'password'
, host=
'localhost'
, dbname=
'dbname'
17
)
18
19
20
class
TestCursor
:
21
def
test_empty_iterable
(self):
22
c =
Cursor
(
None
)
23
result = list(c)
24
assert
result == []
25
26
def
test_escape_basic
(self):
27
query =
"select * from foo where bar > :baz"
28
result = str(
_bind_parameters
(query, {
"baz"
: 10}))
29
expected =
'select * from foo where bar > 10'
30
assert
result == expected
31
32
def
test_escape_malicious
(self):
33
query =
"select * from foo where bar > :baz"
34
result = str(
_bind_parameters
(query, {
"baz"
:
'1; drop table foo'
}))
35
# note the inner quotes
36
expected =
"select * from foo where bar > '1; drop table foo'"
37
assert
result == expected
38
39
def
test_arraysize
(self):
40
c =
Cursor
(
None
)
41
assert
c.arraysize == 1
42
c.arraysize = 10
43
assert
c.arraysize == 10
44
45
with pytest.raises(TypeError):
46
c.arraysize =
'a'
tests.test_cursor.TestCursor
Definition:
test_cursor.py:20
heavydb.connection.connect
def connect
Definition:
connection.py:51
tests.test_cursor.mock_connection
def mock_connection
Definition:
test_cursor.py:7
heavydb.cursor.Cursor
Definition:
cursor.py:6
tests.test_cursor.TestCursor.test_escape_basic
def test_escape_basic
Definition:
test_cursor.py:26
heavydb.cursor
Definition:
cursor.py:1
heavydb._parsers._bind_parameters
def _bind_parameters
Definition:
_parsers.py:162
tests.test_cursor.TestCursor.test_escape_malicious
def test_escape_malicious
Definition:
test_cursor.py:32
tests.test_cursor.TestCursor.test_empty_iterable
def test_empty_iterable
Definition:
test_cursor.py:21
tests.test_cursor.TestCursor.test_arraysize
def test_arraysize
Definition:
test_cursor.py:39
python
tests
test_cursor.py
Generated on Tue Aug 27 2024 00:12:40 for OmniSciDB by
1.8.5