Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_mongo_index_creation():
"""Basic Mongo core functionality."""
collection = _test_mongetter()
_test_mongo_caching.clear_cache()
val1 = _test_mongo_caching(1, 2)
val2 = _test_mongo_caching(1, 2)
assert val1 == val2
assert _MongoCore._INDEX_NAME in collection.index_information()
def __init__(self, mongetter, stale_after, next_time):
if 'pymongo' not in sys.modules:
warnings.warn((
"Cachier warning: pymongo was not found. "
"MongoDB cores will not function."))
_BaseCore.__init__(self, stale_after, next_time)
self.mongetter = mongetter
self.mongo_collection = self.mongetter()
index_inf = self.mongo_collection.index_information()
if _MongoCore._INDEX_NAME not in index_inf:
func1key1 = IndexModel(
keys=[('func', ASCENDING), ('key', ASCENDING)],
name=_MongoCore._INDEX_NAME)
self.mongo_collection.create_indexes([func1key1])
def __init__(self, mongetter, stale_after, next_time):
if 'pymongo' not in sys.modules:
warnings.warn((
"Cachier warning: pymongo was not found. "
"MongoDB cores will not function."))
_BaseCore.__init__(self, stale_after, next_time)
self.mongetter = mongetter
self.mongo_collection = self.mongetter()
index_inf = self.mongo_collection.index_information()
if _MongoCore._INDEX_NAME not in index_inf:
func1key1 = IndexModel(
keys=[('func', ASCENDING), ('key', ASCENDING)],
name=_MongoCore._INDEX_NAME)
self.mongo_collection.create_indexes([func1key1])