mirror of
https://github.com/jazzband/django-constance.git
synced 2026-03-16 22:40:24 +00:00
added standalone test cases
This commit is contained in:
parent
b307e06f86
commit
f616fd82c7
5 changed files with 35 additions and 12 deletions
|
|
@ -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
|
||||
=====
|
||||
|
||||
|
|
|
|||
5
constance/tests/redis_mockup.py
Normal file
5
constance/tests/redis_mockup.py
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
class Connection(dict):
|
||||
def set(self, key, value):
|
||||
self[key] = value
|
||||
|
||||
|
||||
19
constance/tests/runtests.py
Normal file
19
constance/tests/runtests.py
Normal file
|
|
@ -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()
|
||||
|
|
@ -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
|
||||
|
|
|
|||
7
constance/tests/test_settings.py
Normal file
7
constance/tests/test_settings.py
Normal file
|
|
@ -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'
|
||||
Loading…
Reference in a new issue