diff --git a/README.rst b/README.rst index 833dcbe..7378ed2 100644 --- a/README.rst +++ b/README.rst @@ -37,6 +37,10 @@ key you want to turn dynamic into the ``CONSTANCE_CONFIG`` section, like this:: 'MY_SETTINGS_KEY': (42, 'the answer to everything'), } +Here, ``42`` is the default value for the key MY_SETTINGS_KEY if it is not +found in Redis. The other member of the tuple is a help text the admin +will show. + Usage ===== diff --git a/constance/tests/redis_mockup.py b/constance/tests/redis_mockup.py new file mode 100644 index 0000000..0af0017 --- /dev/null +++ b/constance/tests/redis_mockup.py @@ -0,0 +1,5 @@ +class Connection(dict): + def set(self, key, value): + self[key] = value + + diff --git a/constance/tests/runtests.py b/constance/tests/runtests.py new file mode 100644 index 0000000..7a302fc --- /dev/null +++ b/constance/tests/runtests.py @@ -0,0 +1,19 @@ +#!/usr/bin/env python + +"""Borrowed from Carl Meyer's django-adminfiles.""" + +import os, sys + +parent = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) +sys.path.insert(0, parent) + +os.environ['DJANGO_SETTINGS_MODULE'] = 'tests.test_settings' + +from django.test.simple import run_tests + +def runtests(): + failures = run_tests(['tests'], verbosity=1, interactive=True) + sys.exit(failures) + +if __name__ == '__main__': + runtests() diff --git a/constance/tests/test_config.py b/constance/tests/test_config.py index c7243a0..43f79e0 100644 --- a/constance/tests/test_config.py +++ b/constance/tests/test_config.py @@ -7,14 +7,6 @@ from constance import config class TestStorage(TestCase): - def setUp(self): - self.old_config = getattr(settings, 'CONSTANCE_CONFIG', None) - settings.CONSTANCE_CONFIG = { - 'INT_VALUE': (1, 'some int'), - 'BOOL_VALUE': (True, 'true or false'), - 'STRING_VALUE': ('Hello world', 'greetings'), - } - def test_store(self): # read defaults self.assertEquals(config.INT_VALUE, 1) @@ -27,7 +19,3 @@ class TestStorage(TestCase): self.assertEquals(config.INT_VALUE, 100) self.assertEquals(config.BOOL_VALUE, False) self.assertEquals(config.STRING_VALUE, 'Hello world') - - def tearDown(self): - if self.old_config: - settings.CONSTANCE_CONFIG = self.old_config diff --git a/constance/tests/test_settings.py b/constance/tests/test_settings.py new file mode 100644 index 0000000..07402b0 --- /dev/null +++ b/constance/tests/test_settings.py @@ -0,0 +1,7 @@ +CONSTANCE_CONFIG = { + 'INT_VALUE': (1, 'some int'), + 'BOOL_VALUE': (True, 'true or false'), + 'STRING_VALUE': ('Hello world', 'greetings'), +} + +CONSTANCE_CONNECTION_CLASS = 'redis_mockup.Connection'