def test_settings_key_not_exists_with_raise_exception(self): with pytest.raises(SettingKeyNotExists, match=r"SettingKeyNotExists .*"): setting( available_names="NOT_EXISTS_KEY", settings_module=settings, raise_exception=True, )
def test_available_names_type_list_or_tuple(self): value = setting( names=['AWS_SECRETS_MANAGER_SECRET_NAME', 'AWS_SECRET_NAME'], settings_module=settings) assert value == self.AWS_SECRET_NAME value = setting(names=( 'AWS_SECRETS_MANAGER_SECRET_NAME', 'AWS_SECRET_NAME', ), settings_module=settings) assert value == self.AWS_SECRET_NAME
def test_key_not_exists_get_default(self): value = setting( available_names="NOT_EXISTS_KEY", default="Exists Key", settings_module=settings, ) assert value == "Exists Key"
def test_available_names_type_list_or_tuple(self): value = setting( available_names=[ "AWS_SECRETS_MANAGER_SECRET_NAME", "AWS_SECRET_NAME" ], settings_module=settings, ) assert value == self.AWS_SECRET_NAME value = setting( available_names=( "AWS_SECRETS_MANAGER_SECRET_NAME", "AWS_SECRET_NAME", ), settings_module=settings, ) assert value == self.AWS_SECRET_NAME
def test_key_not_exists(self): value = setting(available_names="NOT_EXISTS_KEY", settings_module=settings) assert value is None
def test_get_from_environ(self): os.environ.setdefault("AWS_ENVIRON_SECRET_NAME", self.AWS_SECRET_NAME) value = setting(available_names="AWS_ENVIRON_SECRET_NAME", settings_module=settings) assert value == self.AWS_SECRET_NAME
def test_available_names_type_not_list(self): value = setting(available_names="AWS_SECRET_NAME", settings_module=settings) assert value == self.AWS_SECRET_NAME
def test_settings_key_not_exists_with_raise_exception(self): with pytest.raises(SettingKeyNotExists, match=r'SettingKeyNotExists .*'): setting(names='NOT_EXISTS_KEY', settings_module=settings, raise_exception=True)
def test_key_not_exists_get_default(self): value = setting(names='NOT_EXISTS_KEY', default='Exists Key', settings_module=settings) assert value == 'Exists Key'
def test_key_not_exists(self): value = setting(names='NOT_EXISTS_KEY', settings_module=settings) assert value is None
def test_get_from_environ(self): os.environ.setdefault('AWS_ENVIRON_SECRET_NAME', self.AWS_SECRET_NAME) value = setting(names='AWS_ENVIRON_SECRET_NAME', settings_module=settings) assert value == self.AWS_SECRET_NAME