added standalone test cases

This commit is contained in:
Jiri Barton 2010-08-25 14:11:26 +02:00
parent b307e06f86
commit f616fd82c7
5 changed files with 35 additions and 12 deletions

View file

@ -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
=====

View file

@ -0,0 +1,5 @@
class Connection(dict):
def set(self, key, value):
self[key] = value

View 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()

View file

@ -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

View 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'