-
-
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 3 commits
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 |
|---|---|---|
|
|
@@ -26,16 +26,15 @@ def read(*parts): | |
| 'django-cadmin = configurations.management:execute_from_command_line', | ||
| ], | ||
| }, | ||
| install_requires=[ | ||
| 'django>=2.2', | ||
| 'importlib-metadata;python_version<"3.8"', | ||
|
|
||
| install_requires=['django-environ', | ||
| 'django>=2.2', | ||
| 'importlib-metadata;python_version<"3.8"', | ||
| ], | ||
| extras_require={ | ||
| 'cache': ['django-cache-url'], | ||
| 'database': ['dj-database-url'], | ||
| 'email': ['dj-email-url'], | ||
| 'search': ['dj-search-url'], | ||
| 'testing': [ | ||
| 'django-discover-runner', | ||
auvipy marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| 'mock', | ||
auvipy marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| 'django-cache-url>=1.0.0', | ||
| 'dj-database-url', | ||
| 'dj-email-url', | ||
|
Contributor
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. These 4 packages need to be removed from the |
||
|
|
||
| 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,7 +410,6 @@ 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://'): | ||
| self.assertEqual(value.setup('EMAIL_URL'), { | ||
|
|
@@ -420,17 +418,19 @@ def test_email_url_value(self): | |
| '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='console://'): | ||
| with patch('warnings.warn') as warn: | ||
| value.setup('EMAIL_URL') | ||
| warn.asset_called_once() | ||
| 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', | ||
|
Contributor
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).
Author
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?
Contributor
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 +443,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') | ||
|
Contributor
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"?!
Author
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?
Author
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.
Member
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 +497,6 @@ class Target: | |
| '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.