Skip to content

Commit ca9c705

Browse files
committed
added tests for LazyTableReference init and str
1 parent d8f4456 commit ca9c705

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

tests/columns/test_reference.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
"""
2+
Most of the tests for piccolo/columns/reference.py are covered in
3+
piccolo/columns/test_foreignkey.py
4+
"""
5+
from unittest import TestCase
6+
7+
from piccolo.columns.reference import LazyTableReference
8+
9+
10+
class TestLazyTableReference(TestCase):
11+
def test_init(self):
12+
"""
13+
A ``LazyTableReference`` must be passed either an ``app_name`` or
14+
``module_path`` argument.
15+
"""
16+
with self.assertRaises(ValueError):
17+
LazyTableReference(table_class_name="Manager")
18+
19+
with self.assertRaises(ValueError):
20+
LazyTableReference(
21+
table_class_name="Manager",
22+
app_name="example_app",
23+
module_path="tests.example_app.tables",
24+
)
25+
26+
# Shouldn't raise exceptions:
27+
LazyTableReference(
28+
table_class_name="Manager", app_name="example_app",
29+
)
30+
LazyTableReference(
31+
table_class_name="Manager", module_path="tests.example_app.tables",
32+
)
33+
34+
def test_str(self):
35+
self.assertEqual(
36+
LazyTableReference(
37+
table_class_name="Manager", app_name="example_app",
38+
).__str__(),
39+
"App example_app.Manager",
40+
)
41+
42+
self.assertEqual(
43+
LazyTableReference(
44+
table_class_name="Manager",
45+
module_path="tests.example_app.tables",
46+
).__str__(),
47+
"Module tests.example_app.tables.Manager",
48+
)

0 commit comments

Comments
 (0)