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()
    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()
Exemple #3
0
    def test_store_default_values(self):
        self.assertEqual(Settings.objects.count(), 0)
        call_command('setman_cmd', default_values=True, verbosity=0)
        self.assertEqual(Settings.objects.count(), 1)

        settings = Settings.objects.get()

        for key, value in TEST_SETTINGS.items():
            self.assertEqual(getattr(settings, key), value)

        settings.data = NEW_SETTINGS
        settings.save()

        call_command('setman_cmd', default_values=True, verbosity=0)
        settings = Settings.objects.get()

        for key, value in TEST_SETTINGS.items():
            self.assertEqual(getattr(settings, key), value)
    def test_store_default_values(self):
        self.assertEqual(Settings.objects.count(), 0)
        call_command('setman_cmd', default_values=True, verbosity=0)
        self.assertEqual(Settings.objects.count(), 1)

        settings = Settings.objects.get()

        for key, value in TEST_SETTINGS.items():
            self.assertEqual(getattr(settings, key), value)

        settings.data = NEW_SETTINGS
        settings.save()

        call_command('setman_cmd', default_values=True, verbosity=0)
        settings = Settings.objects.get()

        for key, value in TEST_SETTINGS.items():
            self.assertEqual(getattr(settings, key), value)
Exemple #5
0
    def test_filled_settings(self):
        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)
            )

        for name, value in TEST_SETTINGS.items():
            self.assertEqual(getattr(settings, name), value)
    def test_get_config(self):
        for key, value in TEST_SETTINGS.items():
            if key == 'core':
                continue
            self.assertEqual(get_config(key), value)

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

        for key, value in TEST_SETTINGS['core'].items():
            self.assertEqual(get_config('core.%s' % key), value)
Exemple #7
0
    def test_get_config(self):
        for key, value in TEST_SETTINGS.items():
            if key == 'core':
                continue
            self.assertEqual(get_config(key), value)

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

        for key, value in TEST_SETTINGS['core'].items():
            self.assertEqual(get_config('core.%s' % key), value)
Exemple #8
0
    def test_revert_settings(self):
        Settings.objects.create(data=NEW_SETTINGS)

        client = self.login(TEST_USERNAME)
        response = client.get(self.revert_settings_url)

        self.assertEquals(response.status_code, 302)
        self.assertIn(self.edit_settings_url, response['Location'])

        for key, value in TEST_SETTINGS.items():
            self.assertEqual(getattr(settings, key), value)
Exemple #9
0
    def test_default_values(self):
        self.assertEqual(Settings.objects.count(), 0)

        for name, value in TEST_SETTINGS.items():
            self.assertTrue(hasattr(settings, name))
            self.assertEqual(getattr(settings, name), value)
 def setUp(self):
     Settings.objects.create(data=TEST_SETTINGS.copy())
Exemple #11
0
 def setUp(self):
     Settings.objects.create(data=TEST_SETTINGS.copy())
Exemple #12
0
 def test_get_config(self):
     for key, value in TEST_SETTINGS.items():
         self.assertEqual(get_config(key), value)