-
-
Notifications
You must be signed in to change notification settings - Fork 146
Migrate to django-environ #244
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 1 commit
a8c8796
f376341
499380b
ec51904
3077eaf
fb7417f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,18 +41,11 @@ def find_version(*parts): | |
'django-cadmin = configurations.management:execute_from_command_line', | ||
], | ||
}, | ||
install_requires=['django-environ'], | ||
extras_require={ | ||
'cache': ['django-cache-url'], | ||
'database': ['dj-database-url'], | ||
'email': ['dj-email-url'], | ||
'search': ['dj-search-url'], | ||
'testing': [ | ||
'django-discover-runner', | ||
'mock', | ||
auvipy marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
'django-cache-url>=1.0.0', | ||
'dj-database-url', | ||
'dj-email-url', | ||
'dj-search-url', | ||
'six', | ||
'Sphinx>=1.4', | ||
], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could maybe still be in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks no need here. How useful to keep those in extra_require? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It avoids having to install / installing it by default when not needed. I guess the typical usecase is using URLs for configs then, so that seems to be OK. |
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -374,7 +374,6 @@ def test_database_url_value(self): | |
with env(DATABASE_URL='sqlite://'): | ||
self.assertEqual(value.setup('DATABASE_URL'), { | ||
'default': { | ||
'CONN_MAX_AGE': 0, | ||
'ENGINE': 'django.db.backends.sqlite3', | ||
'HOST': '', | ||
'NAME': ':memory:', | ||
|
@@ -411,26 +410,23 @@ def test_email_url_value(self): | |
'EMAIL_HOST_PASSWORD': 'password', | ||
'EMAIL_HOST_USER': '[email protected]', | ||
'EMAIL_PORT': 587, | ||
'EMAIL_USE_SSL': False, | ||
'EMAIL_USE_TLS': True}) | ||
with env(EMAIL_URL='console://'): | ||
with env(EMAIL_URL='consolemail://'): | ||
|
||
self.assertEqual(value.setup('EMAIL_URL'), { | ||
'EMAIL_BACKEND': 'django.core.mail.backends.console.EmailBackend', # noqa: E501 | ||
'EMAIL_FILE_PATH': '', | ||
'EMAIL_HOST': None, | ||
'EMAIL_HOST_PASSWORD': None, | ||
'EMAIL_HOST_USER': None, | ||
'EMAIL_PORT': None, | ||
'EMAIL_USE_SSL': False, | ||
'EMAIL_USE_TLS': False}) | ||
'EMAIL_PORT': None}) | ||
with env(EMAIL_URL='smtps://[email protected]:[email protected]:wrong'): # noqa: E501 | ||
self.assertRaises(ValueError, value.setup, 'TEST') | ||
|
||
def test_cache_url_value(self): | ||
cache_setting = { | ||
'default': { | ||
'BACKEND': 'django_redis.cache.RedisCache', | ||
'LOCATION': 'redis://host:6379/1', | ||
'LOCATION': 'redis://user@host:6379/1', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Apparently it changes some defaults (more secure by default). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure if I get your point. Is this change acceptable? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It changes defaults apparently, so we should bump the major or at least minor version for it. |
||
} | ||
} | ||
cache_url = 'redis://user@host:6379/1' | ||
|
@@ -443,13 +439,7 @@ def test_cache_url_value(self): | |
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'") | ||
self.assertEqual(cm.exception.args[0], 'wrong') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That looks "wrong"?! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. django-environ simply raises It might be good for django-envion to catch the KeyError and reraise a specific error with more descriptive message. What do you think? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FYI, I made a patch to django-environ, joke2k/django-environ#235 After this patch is accepted and merged, this assertion could be updated accordingly. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @tkdchen , that patch was merged; I guess this can be updated now ? |
||
|
||
def test_search_url_value(self): | ||
value = SearchURLValue() | ||
|
@@ -503,7 +493,6 @@ class Target(object): | |
'EMAIL_HOST_PASSWORD': 'password', | ||
'EMAIL_HOST_USER': '[email protected]', | ||
'EMAIL_PORT': 587, | ||
'EMAIL_USE_SSL': False, | ||
'EMAIL_USE_TLS': True | ||
}) | ||
self.assertEqual( | ||
|
Uh oh!
There was an error while loading. Please reload this page.