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
30 lines (21 loc) · 880 Bytes
/
test_querystring.py
File metadata and controls
30 lines (21 loc) · 880 Bytes
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
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", []))