示例#1
0
 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,
         )
示例#2
0
    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
示例#3
0
    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"
示例#4
0
    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
示例#5
0
    def test_key_not_exists(self):
        value = setting(available_names="NOT_EXISTS_KEY",
                        settings_module=settings)

        assert value is None
示例#6
0
    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
示例#7
0
    def test_available_names_type_not_list(self):
        value = setting(available_names="AWS_SECRET_NAME",
                        settings_module=settings)

        assert value == self.AWS_SECRET_NAME
示例#8
0
 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)
示例#9
0
    def test_key_not_exists_get_default(self):
        value = setting(names='NOT_EXISTS_KEY',
                        default='Exists Key',
                        settings_module=settings)

        assert value == 'Exists Key'
示例#10
0
    def test_key_not_exists(self):
        value = setting(names='NOT_EXISTS_KEY', settings_module=settings)

        assert value is None
示例#11
0
    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