Exemple #1
0
    def test_should_call_functions_in_process_special_settings(self):
        mock = MagicMock()
        settings_dict = {'SIMPLE_SETTINGS': {'foo': mock}}
        with patch.dict(SPECIAL_SETTINGS_MAPPING, {'foo': mock}):
            process_special_settings(settings_dict)

        assert mock.called
    def test_should_call_functions_in_process_special_settings(self):
        mock = MagicMock()
        settings_dict = {'SIMPLE_SETTINGS': {'foo': mock}}
        with patch.dict(SPECIAL_SETTINGS_MAPPING, {'foo': mock}):
            process_special_settings(settings_dict)

        assert mock.called
Exemple #3
0
    def test_override_by_env_and_required_loads_in_correct_order(
            self, settings_dict_override_and_required):
        def mock_env_side_effect(k, d=None):
            return '1' if k == 'SIMPLE_INTEGER' else d

        with patch('os.environ.get', side_effect=mock_env_side_effect):
            process_special_settings(settings_dict_override_and_required)

        assert settings_dict_override_and_required['SIMPLE_INTEGER'] == 1
    def test_override_by_env_and_required_loads_in_correct_order(
        self, settings_dict_override_and_required
    ):
        def mock_env_side_effect(k, d=None):
            return '1' if k == 'SIMPLE_INTEGER' else d

        with patch('os.environ.get', side_effect=mock_env_side_effect):
            process_special_settings(settings_dict_override_and_required)

        assert settings_dict_override_and_required['SIMPLE_INTEGER'] == 1
Exemple #5
0
    def test_should_call_functions_in_process_special_settings(self):
        funcs = MagicMock()

        settings_dict = {
            'SIMPLE_SETTINGS': {
                'bar': 'bar_value',
                'foo': 'foo_value'
            }
        }

        with patch('simple_settings.special_settings.SPECIAL_SETTINGS_MAPPING',
                   OrderedDict((('foo', funcs.foo), ('bar', funcs.bar)))):
            process_special_settings(settings_dict)

        assert funcs.mock_calls == [
            call.foo(settings_dict),
            call.bar(settings_dict)
        ]
    def test_should_call_functions_in_process_special_settings(self):
        funcs = MagicMock()

        settings_dict = {
            'SIMPLE_SETTINGS': {
                'bar': 'bar_value',
                'foo': 'foo_value'
            }
        }

        with patch(
            'simple_settings.special_settings.SPECIAL_SETTINGS_MAPPING',
            OrderedDict((('foo', funcs.foo), ('bar', funcs.bar)))
        ):
            process_special_settings(settings_dict)

        assert funcs.mock_calls == [
            call.foo(settings_dict),
            call.bar(settings_dict)
        ]