Ejemplo n.º 1
0
 def test_py_inside_project(self):
     filepath = os.path.join('.env.py')
     with open(filepath, 'w+') as f:
         f.write('SECRET_KEY = "Not so secret"')
     convertfiletovars()
     secret_key = os.getenv('SECRET_KEY')
     self.assertEqual(secret_key, 'Not so secret')
     os.remove(filepath)
     del os.environ['SECRET_KEY']
Ejemplo n.º 2
0
 def test_yml_outside_project(self):
     filepath = os.path.join(BASE_DIR, '..', '.env.yml')
     with open(filepath, 'w+') as f:
         f.write('SECRET_KEY : "Not so secret"')
     convertfiletovars()
     # import pdb; pdb.set_trace()
     secret_key = os.getenv('SECRET_KEY')
     self.assertEqual(secret_key, 'Not so secret')
     os.remove(filepath)
     del os.environ['SECRET_KEY']
Ejemplo n.º 3
0
 def test_py_inside_project(self):
     """Test that a config file inside of the project folder
     with the .py extension is detected
     """
     filepath = os.path.join('.env.py')
     with open(filepath, 'w+') as f:
         f.write('SECRET_KEY = "Not so secret"')
     convertfiletovars()
     secret_key = os.getenv('SECRET_KEY')
     self.assertEqual(secret_key, 'Not so secret')
     os.remove(filepath)
     del os.environ['SECRET_KEY']
Ejemplo n.º 4
0
 def test_yml_outside_project(self):
     """Test that a config file outside of the project folder
     with the .py extension is detected
     """
     filepath = os.path.join(BASE_DIR, '..', '.env.yml')
     with open(filepath, 'w+') as f:
         f.write('SECRET_KEY : "Not so secret"')
     convertfiletovars()
     # import pdb; pdb.set_trace()
     secret_key = os.getenv('SECRET_KEY')
     self.assertEqual(secret_key, 'Not so secret')
     os.remove(filepath)
     del os.environ['SECRET_KEY']
Ejemplo n.º 5
0
 def test_error_is_raised_when_no_config_file(self):
     """Test that an error message is returned when a config
     file isn't present
     """
     pyfilepath = os.path.join(BASE_DIR, '.env.py')
     ymlfilepath = os.path.join(BASE_DIR, '.env.yml')
     self.assertEqual(IOError, type(Config.parse_file(pyfilepath)))
     self.assertEqual(IOError, type(Config.parse_file(ymlfilepath)))
     pyfilepath = os.path.join(BASE_DIR, '..', '.env.py')
     ymlfilepath = os.path.join(BASE_DIR, '..', '.env.yml')
     self.assertEqual(IOError, type(Config.parse_file(pyfilepath)))
     self.assertEqual(IOError, type(Config.parse_file(ymlfilepath)))
     res = convertfiletovars()
     self.assertIn('No environment file', res)
Ejemplo n.º 6
0
"""
Development specific settings for this project.
"""

from django_envie.workroom import convertfiletovars
convertfiletovars()

from .base import *

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': 'neatpix',
        'USER': os.getenv('DATABASE_USER'),
        'PASSWORD': os.getenv('DATABASE_PASSWORD'),
        'HOST': '127.0.0.1',
        'PORT': '5432',
    }
}
Ejemplo n.º 7
0
"""
Settings package initialization.
"""

import os

# Ensure development settings are not used in production:
if not os.getenv('CI') and not os.getenv('HEROKU'):
    # load and set environment variables from '.env.yml' or '.env.py' files
    # with django_envie
    from django_envie.workroom import convertfiletovars
    convertfiletovars()

    from development import *

if os.getenv('HEROKU') is not None:
    from production import *
Ejemplo n.º 8
0
 def test_an_error_msg_when_no_yml(self):
     res = convertfiletovars()
     self.assertIn('No environment file', res)