mirror of
https://github.com/jazzband/django-constance.git
synced 2026-05-01 12:14:53 +00:00
refatored test project
This commit is contained in:
parent
1354913997
commit
5275718cc2
12 changed files with 57 additions and 7 deletions
|
|
@ -1 +0,0 @@
|
|||
|
||||
|
|
@ -7,13 +7,13 @@ import 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'
|
||||
os.environ['DJANGO_SETTINGS_MODULE'] = 'testproject.settings'
|
||||
|
||||
from django.test.simple import run_tests
|
||||
|
||||
|
||||
def runtests():
|
||||
failures = run_tests(['tests'], verbosity=1, interactive=True)
|
||||
failures = run_tests(['test_app'], verbosity=1, interactive=True)
|
||||
sys.exit(failures)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
|||
0
tests/testproject/models.py
Normal file
0
tests/testproject/models.py
Normal file
|
|
@ -17,12 +17,12 @@ INSTALLED_APPS = (
|
|||
|
||||
'constance',
|
||||
|
||||
'tests',
|
||||
'testproject.test_app',
|
||||
)
|
||||
|
||||
ROOT_URLCONF = 'tests.test_urls'
|
||||
ROOT_URLCONF = 'testproject.test_urls'
|
||||
|
||||
CONSTANCE_CONNECTION_CLASS = 'tests.redis_mockup.Connection'
|
||||
CONSTANCE_CONNECTION_CLASS = 'testproject.test_app.redis_mockup.Connection'
|
||||
|
||||
CONSTANCE_CONFIG = {
|
||||
'INT_VALUE': (1, 'some int'),
|
||||
0
tests/testproject/test_app/__init__.py
Normal file
0
tests/testproject/test_app/__init__.py
Normal file
0
tests/testproject/test_app/models.py
Normal file
0
tests/testproject/test_app/models.py
Normal file
1
tests/testproject/test_app/tests/__init__.py
Normal file
1
tests/testproject/test_app/tests/__init__.py
Normal file
|
|
@ -0,0 +1 @@
|
|||
from testproject.test_app.tests.test_config import *
|
||||
40
tests/testproject/test_app/tests/helpers.py
Normal file
40
tests/testproject/test_app/tests/helpers.py
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
import datetime
|
||||
|
||||
from django.core.handlers.wsgi import WSGIRequest
|
||||
|
||||
|
||||
|
||||
class FakeRequest(WSGIRequest):
|
||||
|
||||
def __init__(self, user=None, meta=None, environ=None, cookies=None):
|
||||
if not environ:
|
||||
environ = {
|
||||
'PATH_INFO': '/',
|
||||
'QUERY_STRING': '',
|
||||
'REMOTE_ADDR': '127.0.0.1',
|
||||
'REQUEST_METHOD': 'GET',
|
||||
'SCRIPT_NAME': '',
|
||||
'SERVER_NAME': 'testserver',
|
||||
'SERVER_PORT': '80',
|
||||
'SERVER_PROTOCOL': 'HTTP/1.1',
|
||||
'wsgi.version': (1,0),
|
||||
'wsgi.url_scheme': 'http',
|
||||
'wsgi.errors': [],
|
||||
'wsgi.multiprocess': True,
|
||||
'wsgi.multithread': False,
|
||||
'wsgi.run_once': False,
|
||||
}
|
||||
super(FakeRequest, self).__init__(environ)
|
||||
if user:
|
||||
self.user = user
|
||||
if meta:
|
||||
self.META.update(meta)
|
||||
if cookies:
|
||||
self.COOKIES.update(cookies)
|
||||
self.xnow = datetime.datetime.now()
|
||||
|
||||
@classmethod
|
||||
def from_test_response(cls, response, *args, **kwargs):
|
||||
return cls(environ=response.request, *args, **kwargs)
|
||||
|
||||
|
||||
|
|
@ -12,7 +12,7 @@ from constance import config
|
|||
from constance.admin import Config
|
||||
|
||||
# Use django RequestFactory later on
|
||||
from helpers import FakeRequest
|
||||
from testproject.test_app.tests.helpers import FakeRequest
|
||||
|
||||
|
||||
|
||||
10
tests/testproject/urls.py
Normal file
10
tests/testproject/urls.py
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
from django.conf.urls.defaults import patterns, include
|
||||
|
||||
urlpatterns = patterns('',
|
||||
# Uncomment the admin/doc line below and add 'django.contrib.admindocs'
|
||||
# to INSTALLED_APPS to enable admin documentation:
|
||||
# (r'^admin/doc/', include('django.contrib.admindocs.urls')),
|
||||
|
||||
(r'^admin/', include(admin.site.urls)),
|
||||
)
|
||||
|
||||
Loading…
Reference in a new issue