forked from piccolo-orm/piccolo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_metaclass.py
More file actions
36 lines (25 loc) · 915 Bytes
/
test_metaclass.py
File metadata and controls
36 lines (25 loc) · 915 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
31
32
33
34
35
36
from unittest import TestCase
from piccolo.table import Table
from ..example_app.tables import Band
class TestMetaClass(TestCase):
def test_tablename(self):
self.assertEqual(Band._meta.tablename, "band")
def test_protected_table_names(self):
"""
Some tablenames are forbidden because they're reserved words in the
database, and can potentially cause issues.
"""
with self.assertRaises(ValueError):
class User(Table):
pass
with self.assertRaises(ValueError):
class MyUser(Table, tablename="user"):
pass
def test_help_text(self):
"""
Make sure help_text can be set for the Table.
"""
help_text = "The manager of a band."
class Manager(Table, help_text=help_text):
pass
self.assertEqual(Manager._meta.help_text, help_text)