From 940cfb802a5d829d6c97331c004bd72e3585e3aa Mon Sep 17 00:00:00 2001 From: Eduardo Calil Date: Thu, 10 Mar 2016 13:31:19 -0300 Subject: [PATCH] Implementa e testa o settings.py utilizando o python-decouple --- sapl/settings.py | 10 +++++----- sapl/test_config.py | 20 ++++++++++++++++++++ 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/sapl/settings.py b/sapl/settings.py index cbaac9a7a..b7f4ee978 100644 --- a/sapl/settings.py +++ b/sapl/settings.py @@ -111,17 +111,17 @@ DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql_psycopg2', 'NAME': config('NAME'), - 'USER': config('USER'), + 'USER': config('SET_USER'), 'PASSWORD': config('PASSWORD'), 'HOST': config('HOST'), 'PORT': config('PORT'), } } -EMAIL_USE_TLS = config('EMAIL_USE_TLS') -EMAIL_HOST = config('EMAIL_HOST') -EMAIL_HOST_USER = config('EMAIL_HOST_USER') -EMAIL_HOST_PASSWORD = config('EMAIL_HOST_PASSWORD') +EMAIL_USE_TLS = config('EMAIL_USE_TLS', cast=bool) +EMAIL_HOST = config('EMAIL_HOST', cast=str) +EMAIL_HOST_USER = config('EMAIL_HOST_USER', cast=str) +EMAIL_HOST_PASSWORD = config('EMAIL_HOST_PASSWORD', cast=str) EMAIL_PORT = config('EMAIL_PORT', cast=int) MAX_DOC_UPLOAD_SIZE = 5*1024*1024 # 5MB diff --git a/sapl/test_config.py b/sapl/test_config.py index 5231c76d2..fa0f8e621 100644 --- a/sapl/test_config.py +++ b/sapl/test_config.py @@ -1,5 +1,25 @@ from .settings import EMAIL_PORT +from .settings import SECRET_KEY +from .settings import DEBUG +from .settings import DATABASES +from .settings import EMAIL_USE_TLS +from .settings import EMAIL_HOST +from .settings import EMAIL_HOST_USER +from .settings import EMAIL_HOST_PASSWORD + +data = DATABASES.get('default') def test_config(): assert EMAIL_PORT == 587 + assert SECRET_KEY == '!9g1-#la+#(oft(v-y1qhy$jk-2$24pdk69#b_jfqyv!*%a_)t' + assert DEBUG is True + assert data.get('NAME') == 'sapl' + assert data.get('USER') == 'sapl' + assert data.get('PASSWORD') == 'sapl' + assert data.get('HOST') == 'localhost' + assert data.get('PORT') == '5432' + assert EMAIL_USE_TLS is True + assert EMAIL_HOST == 'smtp.interlegis.leg.br' + assert EMAIL_HOST_USER == 'sapl-test' + assert EMAIL_HOST_PASSWORD == '2BhCwbGHcZ'