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_engines_cache(self):
from aldjemy.core import Cache, get_engine
self.assertEqual(get_engine('default'), Cache.engines['default'])
self.assertEqual(get_engine('logs'), Cache.engines['logs'])
self.assertEqual(get_engine(), Cache.engines['default'])
self.assertNotEqual(get_engine('default'), get_engine('logs'))
def get_engine(alias='default'):
if alias not in Cache.engines:
engine_string = get_engine_string(alias)
# we have to use autocommit=True, because SQLAlchemy
# is not aware of Django transactions
kw = {}
if engine_string == 'sqlite3':
kw['native_datetime'] = True
pool = DjangoPool(alias=alias, creator=None)
Cache.engines[alias] = create_engine(get_connection_string(alias),
pool=pool, **kw)
return Cache.engines[alias]