Пример #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