forked from piccolo-orm/piccolo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_readable.py
More file actions
29 lines (21 loc) · 803 Bytes
/
test_readable.py
File metadata and controls
29 lines (21 loc) · 803 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
import unittest
from piccolo import columns
from piccolo.table import Table
from piccolo.columns.readable import Readable
class MyTable(Table):
first_name = columns.Varchar()
last_name = columns.Varchar()
@classmethod
def get_readable(cls) -> Readable:
return Readable(
template="%s %s", columns=[cls.first_name, cls.last_name]
)
class TestReadable(unittest.TestCase):
def setUp(self):
MyTable.create_table().run_sync()
MyTable(first_name="Guido", last_name="van Rossum").save().run_sync()
def test_readable(self):
response = MyTable.select(MyTable.get_readable()).run_sync()
self.assertTrue(response[0]["readable"] == "Guido van Rossum")
def tearDown(self):
MyTable.alter().drop_table().run_sync()