Basic testing infrastructure

This commit is contained in:
Mike Korobov 2010-04-24 04:49:23 +06:00
parent fb068bcc21
commit bbf03705c9
14 changed files with 111 additions and 0 deletions

16
TESTING.rst Normal file
View File

@ -0,0 +1,16 @@
Running tests
=============
::
$ cd test_proj
$ ./test.sh
Code coverage report
====================
Install django-coverage app::
$ pip install django-coverage
Then run tests and open test_proj/_coverage/index.html file in browser.

0
test_proj/__init__.py Normal file
View File

View File

11
test_proj/manage.py Executable file
View File

@ -0,0 +1,11 @@
#!/usr/bin/env python
from django.core.management import execute_manager
try:
import settings # Assumed to be in the same directory.
except ImportError:
import sys
sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n" % __file__)
sys.exit(1)
if __name__ == "__main__":
execute_manager(settings)

50
test_proj/settings.py Normal file
View File

@ -0,0 +1,50 @@
# settings for django-admin-tools test project.
import os
PROJECT_PATH = os.path.abspath(os.path.dirname(__file__))
DATABASE_ENGINE = 'sqlite3'
DATABASE_NAME = ':memory:'
SITE_ID = 1
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.load_template_source',
'django.template.loaders.app_directories.load_template_source',
)
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
)
TEMPLATE_CONTEXT_PROCESSORS = (
'django.core.context_processors.auth',
'django.core.context_processors.request',
)
ROOT_URLCONF = 'urls'
TEMPLATE_DIRS = (
PROJECT_PATH + '/templates',
)
INSTALLED_APPS = [
'admin_tools.theming',
'admin_tools.menu',
'admin_tools.dashboard',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.admin',
'test_app',
]
try:
import django_coverage
TEST_RUNNER = 'django_coverage.coverage_runner.run_tests'
COVERAGE_REPORT_HTML_OUTPUT_DIR = os.path.join(PROJECT_PATH, '_coverage')
except ImportError:
pass

View File

@ -0,0 +1 @@
404

View File

@ -0,0 +1 @@
500

9
test_proj/test.sh Executable file
View File

@ -0,0 +1,9 @@
#!/bin/sh
default_tests='dashboard theming menu test_app'
if [ $# -eq 0 ]
then
./manage.py test $default_tests
else
./manage.py test $*
fi

View File

View File

@ -0,0 +1,4 @@
from django.contrib import admin
from test_app.models import MyModel
admin.site.register(MyModel)

View File

@ -0,0 +1,4 @@
from django.db import models
class MyModel(models.Model):
pass

View File

@ -0,0 +1,5 @@
from django.test import TestCase
class AdminBasicTest(TestCase):
def test_admin_loads(self):
self.client.get('/admin/')

View File

@ -0,0 +1 @@
# Create your views here.

9
test_proj/urls.py Normal file
View File

@ -0,0 +1,9 @@
from django.conf.urls.defaults import *
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
(r'^admin/', include(admin.site.urls)),
url(r'^admin_tools/', include('admin_tools.urls')),
)