Skip to content

Commit 3ead8b9

Browse files
committed
Create collection using manage command
1 parent 66212bc commit 3ead8b9

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

tests/cache_/tests.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
from bson import SON
88
from django.conf import settings
9+
from django.core import management
910
from django.core.cache import DEFAULT_CACHE_ALIAS, CacheKeyWarning, cache, caches
1011
from django.core.cache.backends.base import InvalidCacheBackendError
1112
from django.http import (
@@ -17,8 +18,6 @@
1718
)
1819
from django.test import RequestFactory, TestCase, modify_settings, override_settings
1920

20-
from django_mongodb_backend.cache import MongoDBCache
21-
2221
from .models import Poll, expensive_calculation
2322

2423
KEY_ERRORS_WITH_MEMCACHED_MSG = (
@@ -966,13 +965,7 @@ def drop_collection(self):
966965
cache.collection.drop()
967966

968967
def create_cache_collection(self):
969-
for cache_alias in settings.CACHES:
970-
cache = caches[cache_alias]
971-
connection = cache._db
972-
if cache._collection_name in connection.introspection.table_names():
973-
return
974-
cache = MongoDBCache(cache._collection_name, {})
975-
cache.create_indexes()
968+
management.call_command("createcachecollection", verbosity=0)
976969

977970

978971
@override_settings(USE_TZ=True)

0 commit comments

Comments
 (0)