forked from piccolo-orm/piccolo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_get_related.py
More file actions
30 lines (20 loc) · 780 Bytes
/
test_get_related.py
File metadata and controls
30 lines (20 loc) · 780 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 tests.example_app.tables import Manager, Band
TABLES = [Manager, Band]
class TestGetRelated(TestCase):
def setUp(self):
for table in TABLES:
table.create_table().run_sync()
def tearDown(self):
for table in reversed(TABLES):
table.alter().drop_table().run_sync()
def test_get_related(self):
"""
Make sure you can get a related object from another object instance.
"""
manager = Manager(name="Guido")
manager.save().run_sync()
band = Band(name="Pythonistas", manager=manager.id, popularity=100)
band.save().run_sync()
_manager = band.get_related(Band.manager).run_sync()
self.assertTrue(_manager.name == "Guido")