forked from piccolo-orm/piccolo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_querystring.py
More file actions
55 lines (42 loc) · 1.22 KB
/
test_querystring.py
File metadata and controls
55 lines (42 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
from unittest import TestCase
from piccolo.querystring import QueryString
# TODO - add more extensive tests (increased nesting and argument count).
class TestQuerystring(TestCase):
qs = QueryString(
'SELECT id FROM band {}',
QueryString(
"WHERE name = {}",
'Pythonistas'
)
)
def test_compile_string(self):
compiled_string, args = self.qs.compile_string()
self.assertEqual(
compiled_string,
"SELECT id FROM band WHERE name = $1"
)
self.assertEqual(
args,
['Pythonistas']
)
def test_string(self):
string = self.qs.__str__()
self.assertEqual(
string,
"SELECT id FROM band WHERE name = 'Pythonistas'"
)
def test_querystring_with_no_args(self):
qs = QueryString(
'SELECT name FROM band',
)
self.assertEqual(
qs.compile_string(),
('SELECT name FROM band', [])
)
# class TestExecuteQuerystring(TestCase):
# def setUp():
# Band.create().run_sync()
# def tearDown():
# Band.drop().run_sync()
# def test_raw_query(self):
# Band._meta.db.run()