forked from piccolo-orm/piccolo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_combination.py
More file actions
36 lines (27 loc) · 1.07 KB
/
test_combination.py
File metadata and controls
36 lines (27 loc) · 1.07 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
import unittest
from ..example_app.tables import Band
class TestWhere(unittest.TestCase):
def test_equals(self):
_where = Band.name == "Pythonistas"
sql = _where.__str__()
self.assertEqual(sql, "band.name = 'Pythonistas'")
def test_not_equal(self):
_where = Band.name != "CSharps"
sql = _where.__str__()
self.assertEqual(sql, "band.name != 'CSharps'")
def test_like(self):
_where = Band.name.like("Python%")
sql = _where.__str__()
self.assertEqual(sql, "band.name LIKE 'Python%'")
def test_is_in(self):
_where = Band.name.is_in(["Pythonistas", "Rustaceans"])
sql = _where.__str__()
self.assertEqual(sql, "band.name IN ('Pythonistas', 'Rustaceans')")
with self.assertRaises(ValueError):
Band.name.is_in([])
def test_not_in(self):
_where = Band.name.not_in(["CSharps"])
sql = _where.__str__()
self.assertEqual(sql, "band.name NOT IN ('CSharps')")
with self.assertRaises(ValueError):
Band.name.not_in([])