def test_environment_loads_custom_production_environment(self): env_path = os.path.join(os.getcwd(), '.env') if not os.path.exists(env_path): env_file = open(env_path, 'w') env_file.write('APP_ENV=production') env_file.close() LoadEnvironment() assert os.environ.get('TEST_PRODUCTION') == 'TEST'
"""Database Settings.""" import logging from masonite import env from masonite.environment import LoadEnvironment from orator import DatabaseManager, Model """Load Environment Variables Loads in the environment variables when this page is imported. """ LoadEnvironment() """Database Settings Set connection database settings here as a dictionary. Follow the format below to create additional connection settings. Each key is a connection, not a driver. You may have as many connections as you need. Supported Drivers: 'sqlite', 'mysql', 'postgres' """ DATABASES = { 'default': env('DB_CONNECTION'), 'sqlite': { 'driver': 'sqlite', 'database': env('DB_DATABASE'), 'log_queries': env('DB_LOG'), },
def test_environment_loads_custom_env(self): LoadEnvironment('local') self.assertIn('LOCAL', os.environ) self.assertEqual(os.environ.get('LOCAL'), 'TEST')
def test_environment_only_loads(self): LoadEnvironment(only='local') self.assertIn('LOCAL', os.environ) self.assertEqual(os.environ.get('LOCAL'), 'TEST')
def test_environment_only_loads(self): LoadEnvironment(only='local') assert 'LOCAL' in os.environ assert os.environ.get('LOCAL') == 'TEST'
def test_environment_loads_custom_env(self): LoadEnvironment('local') assert 'LOCAL' in os.environ assert os.environ.get('LOCAL') == 'TEST'
def load_environment(self): LoadEnvironment()