forked from piccolo-orm/piccolo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_boolean.py
More file actions
33 lines (24 loc) · 921 Bytes
/
test_boolean.py
File metadata and controls
33 lines (24 loc) · 921 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
31
32
33
from unittest import TestCase
from piccolo.table import Table
from piccolo.columns.column_types import Boolean
class MyTable(Table):
boolean = Boolean(boolean=False, null=True)
class TestBoolean(TestCase):
def setUp(self):
MyTable.create_table().run_sync()
def tearDown(self):
MyTable.alter().drop_table().run_sync()
def test_return_type(self):
for value in (True, False, None, ...):
kwargs = {} if value is ... else {"boolean": value}
expected = MyTable.boolean.default if value is ... else value
row = MyTable(**kwargs)
row.save().run_sync()
self.assertEqual(row.boolean, expected)
self.assertEqual(
MyTable.select(MyTable.boolean)
.where(MyTable.id == row.id)
.first()
.run_sync()["boolean"],
expected,
)