def test_cache_url_value(self): value = CacheURLValue() self.assertEqual(value.default, {}) with env(CACHE_URL='redis://user@host:port/1'): self.assertEqual(value.setup('CACHE_URL'), { 'default': { 'BACKEND': 'redis_cache.cache.RedisCache', 'KEY_PREFIX': '', 'LOCATION': 'user@host:port:1' }}) with env(CACHE_URL='wrong://user@host:port/1'): self.assertRaises(KeyError, value.setup, 'TEST')
def test_cache_url_value(self): cache_setting = { "default": {"BACKEND": "redis_cache.cache.RedisCache", "KEY_PREFIX": "", "LOCATION": "host:port:1"} } cache_url = "redis://user@host:port/1" value = CacheURLValue(cache_url) self.assertEqual(value.default, cache_setting) value = CacheURLValue() self.assertEqual(value.default, {}) with env(CACHE_URL="redis://user@host:port/1"): self.assertEqual(value.setup("CACHE_URL"), cache_setting) with env(CACHE_URL="wrong://user@host:port/1"): self.assertRaises(KeyError, value.setup, "TEST")
def test_cache_url_value(self): cache_setting = { 'default': { 'BACKEND': 'django_redis.cache.RedisCache', 'LOCATION': 'host:12345:1' } } cache_url = 'redis://user@host:12345/1' value = CacheURLValue(cache_url) self.assertEqual(value.default, cache_setting) value = CacheURLValue() self.assertEqual(value.default, {}) with env(CACHE_URL='redis://user@host:12345/1'): self.assertEqual(value.setup('CACHE_URL'), cache_setting) with env(CACHE_URL='wrong://user@host:12345/1'): self.assertRaisesRegexp(Exception, 'Unknown backend: "wrong"', value.setup, 'TEST')
def test_cache_url_value(self): cache_setting = { 'default': { 'BACKEND': 'django_redis.cache.RedisCache', 'LOCATION': 'host:6379:1' } } cache_url = 'redis://user@host:6379/1' value = CacheURLValue(cache_url) self.assertEqual(value.default, cache_setting) value = CacheURLValue() self.assertEqual(value.default, {}) with env(CACHE_URL='redis://user@host:6379/1'): self.assertEqual(value.setup('CACHE_URL'), cache_setting) with env(CACHE_URL='wrong://user@host:port/1'): with self.assertRaises(Exception) as cm: value.setup('TEST') self.assertEqual(cm.exception.args[0], 'Unknown backend: "wrong"') with env(CACHE_URL='redis://user@host:port/1'): with self.assertRaises(ValueError) as cm: value.setup('TEST') self.assertEqual( cm.exception.args[0], "Cannot interpret cache URL value 'redis://user@host:port/1'")
class DeploymentConfig(object): # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = 'replacethiswithsomethingsecret' # SECURITY WARNING: don't run with debug turned on in production! # Set this to True while you are developing DEBUG = BooleanValue(True) POLIS_SITE_ID = Value(None) # Unrestricted staging key (disposable) GMAPS_API_KEY = Value('AIzaSyDVJdClcbq1ioJUeySpPgNiDndQEspN6Ck') # Set this to a "frozen version" in production # See: https://developers.google.com/maps/documentation/javascript/versions#the-frozen-version GMAPS_API_VERSION = Value('3.exp') # See: https://django-configurations.readthedocs.org/en/stable/values/#configurations.values.DatabaseURLValue DATABASES = DatabaseURLValue('sqlite:///tor_councilmatic.db') # See: https://django-configurations.readthedocs.org/en/stable/values/#configurations.values.SearchURLValue # See: https://github.com/dstufft/dj-search-url HAYSTACK_CONNECTIONS = SearchURLValue('simple://') # See: https://django-configurations.readthedocs.org/en/stable/values/#configurations.values.CacheURLValue # See: https://github.com/ghickman/django-cache-url CACHES = CacheURLValue('dummy://') # Set this to flush the cache at /flush-cache/{FLUSH_KEY} FLUSH_KEY = 'super secret junk' # Set this to allow Disqus comments to render DISQUS_SHORTNAME = None # analytics tracking code ANALYTICS_TRACKING_CODE = Value('') HEADSHOT_PATH = os.path.join(os.path.dirname(__file__), '..' '/toronto/static/images/') EXTRA_APPS = ()
def test_cache_url_value(self): cache_setting = { 'default': { 'BACKEND': 'django_redis.cache.RedisCache', 'LOCATION': 'host:6379:1' } } cache_url = 'redis://user@host:6379/1' value = CacheURLValue(cache_url) self.assertEqual(value.default, cache_setting) value = CacheURLValue() self.assertEqual(value.default, {}) with env(CACHE_URL='redis://user@host:6379/1'): self.assertEqual(value.setup('CACHE_URL'), cache_setting) with env(CACHE_URL='wrong://user@host:port/1'): with self.assertRaises(Exception) as cm: value.setup('TEST') self.assertEqual(cm.exception.args[0], 'Unknown backend: "wrong"') with env(CACHE_URL='redis://user@host:port/1'): with self.assertRaises(ValueError) as cm: value.setup('TEST') self.assertEqual(cm.exception.args[0], "Cannot interpret cache URL value 'redis://user@host:port/1'")