def test_testing_default(self): """ Make sure the testing profile is used when needed. """ app = ProfileApp().init(use_test_profile=True) assert app.config['PROFILE_FROM'] == 'testing-default' app = ProfileApp.testing_prep() assert app.config['PROFILE_FROM'] == 'testing-default'
def test_environment(self): """ The environment override should work even when in a testing context. """ kwargs = {'KEG_APPS_PROFILE_CONFIG_PROFILE': 'EnvironmentProfile'} with mock.patch.dict(os.environ, **kwargs): app = ProfileApp().init() assert app.config['PROFILE_FROM'] == 'environment' app = ProfileApp().init(use_test_profile=True) assert app.config['PROFILE_FROM'] == 'environment'
def test_config_file_default(self): """ No explicit profile and no environment value results in the default coming from configuration profiles. """ app = ProfileApp().init() assert app.config['PROFILE_FROM'] == 'config-file-default'
def test_app_init(self): """ Even with an environment set, the explict value passed into init() should override. """ # the direct setting should override the environment kwargs = {'KEG_APPS.PROFILE_CONFIG_PROFILE': 'EnvironmentProfile'} with mock.patch.dict(os.environ, **kwargs): app = ProfileApp().init(config_profile='AppInitProfile', use_test_profile=True) assert app.config['PROFILE_FROM'] == 'app-init'