forked from piccolo-orm/piccolo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_reference.py
More file actions
48 lines (41 loc) · 1.43 KB
/
test_reference.py
File metadata and controls
48 lines (41 loc) · 1.43 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
37
38
39
40
41
42
43
44
45
46
47
48
"""
Most of the tests for piccolo/columns/reference.py are covered in
piccolo/columns/test_foreignkey.py
"""
from unittest import TestCase
from piccolo.columns.reference import LazyTableReference
class TestLazyTableReference(TestCase):
def test_init(self):
"""
A ``LazyTableReference`` must be passed either an ``app_name`` or
``module_path`` argument.
"""
with self.assertRaises(ValueError):
LazyTableReference(table_class_name="Manager")
with self.assertRaises(ValueError):
LazyTableReference(
table_class_name="Manager",
app_name="example_app",
module_path="tests.example_app.tables",
)
# Shouldn't raise exceptions:
LazyTableReference(
table_class_name="Manager", app_name="example_app",
)
LazyTableReference(
table_class_name="Manager", module_path="tests.example_app.tables",
)
def test_str(self):
self.assertEqual(
LazyTableReference(
table_class_name="Manager", app_name="example_app",
).__str__(),
"App example_app.Manager",
)
self.assertEqual(
LazyTableReference(
table_class_name="Manager",
module_path="tests.example_app.tables",
).__str__(),
"Module tests.example_app.tables.Manager",
)