Optimized inspectdb tests by specifying database tables/views.
This commit is contained in:
parent
1fb97fb965
commit
be183fc94f
|
@ -19,6 +19,13 @@ def inspectdb_tables_only(table_name):
|
|||
return table_name.startswith('inspectdb_')
|
||||
|
||||
|
||||
def inspectdb_views_only(table_name):
|
||||
return (
|
||||
table_name.startswith('inspectdb_') and
|
||||
table_name.endswith(('_materialized', '_view'))
|
||||
)
|
||||
|
||||
|
||||
def special_table_only(table_name):
|
||||
return table_name.startswith('inspectdb_special')
|
||||
|
||||
|
@ -337,11 +344,20 @@ class InspectDBTransactionalTests(TransactionTestCase):
|
|||
view_model = 'class InspectdbPeopleView(models.Model):'
|
||||
view_managed = 'managed = False # Created from a view.'
|
||||
try:
|
||||
call_command('inspectdb', table_name_filter=inspectdb_tables_only, stdout=out)
|
||||
call_command(
|
||||
'inspectdb',
|
||||
table_name_filter=inspectdb_views_only,
|
||||
stdout=out,
|
||||
)
|
||||
no_views_output = out.getvalue()
|
||||
self.assertNotIn(view_model, no_views_output)
|
||||
self.assertNotIn(view_managed, no_views_output)
|
||||
call_command('inspectdb', table_name_filter=inspectdb_tables_only, include_views=True, stdout=out)
|
||||
call_command(
|
||||
'inspectdb',
|
||||
table_name_filter=inspectdb_views_only,
|
||||
include_views=True,
|
||||
stdout=out,
|
||||
)
|
||||
with_views_output = out.getvalue()
|
||||
self.assertIn(view_model, with_views_output)
|
||||
self.assertIn(view_managed, with_views_output)
|
||||
|
@ -361,11 +377,20 @@ class InspectDBTransactionalTests(TransactionTestCase):
|
|||
view_model = 'class InspectdbPeopleMaterialized(models.Model):'
|
||||
view_managed = 'managed = False # Created from a view.'
|
||||
try:
|
||||
call_command('inspectdb', table_name_filter=inspectdb_tables_only, stdout=out)
|
||||
call_command(
|
||||
'inspectdb',
|
||||
table_name_filter=inspectdb_views_only,
|
||||
stdout=out,
|
||||
)
|
||||
no_views_output = out.getvalue()
|
||||
self.assertNotIn(view_model, no_views_output)
|
||||
self.assertNotIn(view_managed, no_views_output)
|
||||
call_command('inspectdb', table_name_filter=inspectdb_tables_only, include_views=True, stdout=out)
|
||||
call_command(
|
||||
'inspectdb',
|
||||
table_name_filter=inspectdb_views_only,
|
||||
include_views=True,
|
||||
stdout=out,
|
||||
)
|
||||
with_views_output = out.getvalue()
|
||||
self.assertIn(view_model, with_views_output)
|
||||
self.assertIn(view_managed, with_views_output)
|
||||
|
@ -426,7 +451,11 @@ class InspectDBTransactionalTests(TransactionTestCase):
|
|||
foreign_table_model = 'class InspectdbIrisForeignTable(models.Model):'
|
||||
foreign_table_managed = 'managed = False'
|
||||
try:
|
||||
call_command('inspectdb', stdout=out)
|
||||
call_command(
|
||||
'inspectdb',
|
||||
table_name_filter=inspectdb_tables_only,
|
||||
stdout=out,
|
||||
)
|
||||
output = out.getvalue()
|
||||
self.assertIn(foreign_table_model, output)
|
||||
self.assertIn(foreign_table_managed, output)
|
||||
|
|
Loading…
Reference in New Issue