Skip to content

Commit e9cf6c4

Browse files
authored
extra test for table sorting (piccolo-orm#227)
* extra test for table sorting * add a test with only a single table
1 parent 27d6f5b commit e9cf6c4

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

tests/apps/migrations/auto/test_migration_manager.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from piccolo.columns.base import OnDelete, OnUpdate
1212
from piccolo.columns.column_types import ForeignKey
1313
from piccolo.conf.apps import AppConfig
14+
from piccolo.table import Table
1415
from piccolo.utils.lazy_loader import LazyLoader
1516
from tests.base import DBTestCase, postgres_only, set_mock_return_value
1617
from tests.example_app.tables import Band, Concert, Manager, Venue
@@ -34,6 +35,29 @@ def test_sort_table_classes(self):
3435
sorted_tables.index(Band) < sorted_tables.index(Concert)
3536
)
3637

38+
def test_sort_unrelated_tables(self):
39+
"""
40+
Make sure there are no weird edge cases with tables with no foreign
41+
key relationships with each other.
42+
"""
43+
44+
class TableA(Table):
45+
pass
46+
47+
class TableB(Table):
48+
pass
49+
50+
self.assertEqual(
51+
sort_table_classes([TableA, TableB]), [TableA, TableB]
52+
)
53+
54+
def test_single_table(self):
55+
"""
56+
Make sure that sorting a list with only a single table in it still
57+
works.
58+
"""
59+
self.assertEqual(sort_table_classes([Band]), [Band])
60+
3761

3862
class TestMigrationManager(DBTestCase):
3963
@postgres_only

0 commit comments

Comments
 (0)