Пример #1
0
    def test_filled_settings(self):
        def check_values(prefix=None):
            data = TEST_SETTINGS[prefix] if prefix else TEST_SETTINGS
            values = getattr(settings, prefix) if prefix else settings

            for name, value in data.items():
                mixed = getattr(values, name)

                if is_settings_container(mixed):
                    check_values(name)
                else:
                    self.assertEqual(mixed, value)

        self.assertEqual(Settings.objects.count(), 0)

        instance = Settings.objects.create(data=TEST_SETTINGS)
        self.assertEqual(instance.data, TEST_SETTINGS)

        for name, value in TEST_SETTINGS.items():
            self.assertEqual(getattr(instance, name), value)

        for name in dir(django_settings):
            if not name.isupper():
                continue

            self.assertEqual(getattr(django_settings, name),
                             getattr(settings, name))

        check_values()
Пример #2
0
    def test_get_config(self):
        for key, value in TEST_SETTINGS.items():
            if key == 'testapp':
                continue
            self.assertEqual(get_config(key), value)

        self.assertRaises(ValueError, get_config, 'testapp')

        for key, value in TEST_SETTINGS['testapp'].items():
            self.assertEqual(get_config('testapp.%s' % key), value)
Пример #3
0
    def test_get_config(self):
        for key, value in TEST_SETTINGS.items():
            if key == 'testapp':
                continue
            self.assertEqual(get_config(key), value)

        self.assertRaises(ValueError, get_config, 'testapp')

        for key, value in TEST_SETTINGS['testapp'].items():
            self.assertEqual(get_config('testapp.%s' % key), value)