forked from piccolo-orm/piccolo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_mixins.py
More file actions
28 lines (20 loc) · 881 Bytes
/
test_mixins.py
File metadata and controls
28 lines (20 loc) · 881 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
from unittest import TestCase
from piccolo.query.mixins import ColumnsDelegate
from tests.example_apps.music.tables import Band
class TestColumnsDelegate(TestCase):
def test_list_unpacking(self):
"""
The ``ColumnsDelegate`` should unpack a list of columns if passed in by
mistake, without the user unpacking them explicitly.
.. code-block:: python
# These two should both work the same:
await Band.select([Band.id, Band.name]).run()
await Band.select(Band.id, Band.name).run()
"""
columns_delegate = ColumnsDelegate()
columns_delegate.columns([Band.name])
self.assertEqual(columns_delegate.selected_columns, [Band.name])
columns_delegate.columns([Band.id])
self.assertEqual(
columns_delegate.selected_columns, [Band.name, Band.id]
)