refatored test project

This commit is contained in:
Ales Zoulek 2010-11-12 15:38:59 +01:00
parent 1354913997
commit 5275718cc2
12 changed files with 57 additions and 7 deletions

View file

@ -1 +0,0 @@

View file

@ -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__':

View file

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

View file

View file

View file

@ -0,0 +1 @@
from testproject.test_app.tests.test_config import *

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

View file

@ -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
View 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)),
)