Fixed #24560 -- Added a --dry-run mode to the createcachetable command.

This commit is contained in:
Adam Chainz 2015-04-01 22:33:27 +01:00 committed by Tim Graham
parent 727e40c879
commit 5564d0f2ee
5 changed files with 40 additions and 4 deletions

11
tests/cache/tests.py vendored
View file

@ -943,6 +943,17 @@ class DBCacheTests(BaseCacheTests, TransactionTestCase):
self.assertEqual(out.getvalue(),
"Cache table 'test cache table' already exists.\n" * len(settings.CACHES))
@override_settings(CACHES=caches_setting_for_tests(
BACKEND='django.core.cache.backends.db.DatabaseCache',
# Use another table name to avoid the 'table already exists' message.
LOCATION='createcachetable_dry_run_mode'
))
def test_createcachetable_dry_run_mode(self):
out = six.StringIO()
management.call_command('createcachetable', dry_run=True, stdout=out)
output = out.getvalue()
self.assertTrue(output.startswith("CREATE TABLE"))
def test_createcachetable_with_table_argument(self):
"""
Delete and recreate cache table with legacy behavior (explicitly