1
0
mirror of https://github.com/django/django.git synced 2025-07-05 10:19:20 +00:00

r10904@kevin-kubasiks-macbook: kkubasik | 2009-06-23 13:14:52 -0600

[gsoc2009-testing] Introduced windmill tests for several contrib components in the admin. Made new runner framework backwords compatible with old style test runners. Added the option to run just the windmill tests in the regressionsuite.


git-svn-id: http://code.djangoproject.com/svn/django/branches/soc2009/test-improvements@11092 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Kevin Kubasik 2009-06-23 19:16:31 +00:00
parent fdedd33bd4
commit 2483e06bd3
5 changed files with 206 additions and 10 deletions

View File

@ -25,7 +25,10 @@ class Command(BaseCommand):
cover = options.get('coverage', False)
report = options.get('reports', False)
test_runner = get_runner(settings, coverage=cover, reports=report)
tr = test_runner()
failures = tr.run_tests(test_labels, verbosity=verbosity, interactive=interactive)
if(type(test_runner) == 'function'):
failures = test_runner(test_labels, verbosity=verbosity, interactive=interactive)
else:
tr = test_runner()
failures = tr.run_tests(test_labels, verbosity=verbosity, interactive=interactive)
if failures:
sys.exit(failures)

View File

@ -3,6 +3,10 @@ from django.contrib import admin
import views
import customadmin
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
(r'^admin/doc/', include('django.contrib.admindocs.urls')),
(r'^admin/secure-view/$', views.secure_view),

View File

@ -343,4 +343,162 @@ def test_recordingSuite7():
client.waits.forPageLoad(timeout=u'20000')
client.waits.forElement(link=u' Home ', timeout=u'8000')
client.click(link=u' Home ')
client.waits.forPageLoad(timeout=u'20000')
client.waits.forPageLoad(timeout=u'20000')
def test_recordingSuite8():
client = WindmillTestClient(__name__)
client.open(url="http://localhost:8000/test_admin/admin")
client.waits.forPageLoad(timeout=u'20000')
client.waits.forElement(xpath=u"//div[@id='content-main']/div/table/tbody/tr[21]/td/a", timeout=u'8000')
client.click(xpath=u"//div[@id='content-main']/div/table/tbody/tr[21]/td/a")
client.click(name=u'_save')
client.waits.forPageLoad(timeout=u'20000')
client.click(link=u'Recommender object')
client.waits.forPageLoad(timeout=u'20000')
client.click(link=u'Home')
client.waits.forPageLoad(timeout=u'20000')
client.click(xpath=u"//div[@id='content-main']/div/table/tbody/tr[20]/td/a")
client.click(id=u'id_recommender')
client.select(option=u'Recommender object', id=u'id_recommender')
client.click(value=u'1')
client.click(name=u'_save')
client.waits.forPageLoad(timeout=u'20000')
client.click(link=u'Languages')
client.waits.forPageLoad(timeout=u'20000')
client.click(link=u' Add language ')
client.waits.forPageLoad(timeout=u'20000')
client.type(text=u'en', id=u'id_iso')
client.type(text=u'testEnglish', id=u'id_name')
client.type(text=u'test', id=u'id_english_name')
client.click(xpath=u"//form[@id='language_form']/div/fieldset/div[4]/div/label")
client.check(id=u'id_shortlist')
client.click(name=u'_save')
client.waits.forPageLoad(timeout=u'20000')
client.click(link=u' Home ')
client.waits.forPageLoad(timeout=u'20000')
def test_AdminAuthContrib():
client = WindmillTestClient(__name__)
client.open(url="http://localhost:8000/test_admin/admin")
client.waits.forPageLoad(timeout=u'20000')
client.waits.forElement(link=u'Users', timeout=u'8000')
client.click(link=u'Users')
client.waits.forPageLoad(timeout=u'20000')
client.asserts.assertNode(link=u'adduser')
client.asserts.assertNode(link=u'admin')
client.asserts.assertNode(link=u'changeuser')
client.asserts.assertNode(link=u'deleteuser')
client.asserts.assertNode(link=u'joepublic')
client.asserts.assertNode(link=u'super')
client.click(link=u'Yes')
client.waits.forPageLoad(timeout=u'20000')
client.asserts.assertNode(link=u'adduser')
client.asserts.assertNode(link=u'admin')
client.asserts.assertNode(link=u'changeuser')
client.asserts.assertNode(link=u'deleteuser')
client.asserts.assertNode(link=u'super')
client.click(link=u'6 total')
client.waits.forPageLoad(timeout=u'20000')
client.waits.forElement(link=u'super', timeout=u'8000')
client.click(link=u'super')
client.waits.forPageLoad(timeout=u'20000')
client.waits.forElement(link=u'Clear all', timeout=u'8000')
client.click(link=u'Clear all')
client.click(link=u'Choose all')
client.click(name=u'_continue')
client.waits.forPageLoad(timeout=u'20000')
client.asserts.assertValue(validator=u'2007-05-30', id=u'id_date_joined_0')
client.asserts.assertValue(validator=u'13:20:10', id=u'id_date_joined_1')
client.asserts.assertValue(validator=u'Super', id=u'id_first_name')
client.asserts.assertValue(validator=u'User', id=u'id_last_name')
client.asserts.assertValue(validator=u'super@example.com', id=u'id_email')
client.asserts.assertValue(validator=u'on', id=u'id_is_staff')
client.asserts.assertValue(validator=u'on', id=u'id_is_active')
client.asserts.assertValue(validator=u'on', id=u'id_is_superuser')
client.asserts.assertValue(validator=u'super', id=u'id_username')
client.click(link=u'Users')
client.waits.forPageLoad(timeout=u'20000')
client.type(text=u'super', id=u'searchbar')
client.click(value=u'Search')
client.waits.forPageLoad(timeout=u'20000')
client.asserts.assertNode(link=u'super')
client.click(link=u'6 total')
client.waits.forPageLoad(timeout=u'20000')
client.waits.forElement(link=u' Home ', timeout=u'8000')
client.click(link=u' Home ')
client.waits.forPageLoad(timeout=u'20000')
def test_contribFlatSitesRedirect():
client = WindmillTestClient(__name__)
client.open(url="http://localhost:8000/test_admin/admin")
client.waits.forPageLoad(timeout=u'20000')
client.click(xpath=u"//div[@id='content-main']/div[4]/table/tbody/tr[1]/td/a")
client.click(id=u'id_url')
client.type(text=u'/testflat/test/', id=u'id_url')
client.type(text=u'Test Flat', id=u'id_title')
client.type(text=u'This is some unique test content.', id=u'id_content')
client.click(value=u'1')
client.click(id=u'fieldsetcollapser1')
client.check(id=u'id_enable_comments')
client.click(name=u'_save')
client.waits.forPageLoad(timeout=u'20000')
client.click(link=u'/testflat/test/')
client.waits.forPageLoad(timeout=u'20000')
client.click(link=u'Home')
client.waits.forPageLoad(timeout=u'20000')
client.click(link=u'Flat pages')
client.waits.forPageLoad(timeout=u'20000')
client.click(link=u' Home ')
client.waits.forPageLoad(timeout=u'20000')
client.click(xpath=u"//div[@id='content-main']/div[6]/table/tbody/tr[1]/th/a")
client.waits.forPageLoad(timeout=u'20000')
client.click(link=u'example.com')
client.waits.forPageLoad(timeout=u'20000')
client.click(id=u'id_domain')
client.doubleClick(id=u'id_domain')
client.type(text=u'localhost', id=u'id_domain')
client.click(name=u'_save')
client.waits.forPageLoad(timeout=u'20000')
client.click(link=u' Home ')
client.waits.forPageLoad(timeout=u'20000')
client.click(link=u'Flat pages')
client.waits.forPageLoad(timeout=u'20000')
client.click(link=u'/testflat/test/')
client.waits.forPageLoad(timeout=u'20000')
client.click(link=u'View on site')
client.waits.forPageLoad(timeout=u'20000')
client.asserts.assertText(xpath=u'/html/body', validator=u'This is some unique test content. ')
client.goBack()
client.waits.forPageLoad(timeout=u'20000')
client.click(link=u'Home')
client.waits.forPageLoad(timeout=u'20000')
client.click(xpath=u"//div[@id='content-main']/div[5]/table/tbody/tr[1]/th/a")
client.waits.forPageLoad(timeout=u'20000')
client.click(link=u' Add redirect ')
client.waits.forPageLoad(timeout=u'20000')
client.click(xpath=u"//ul[@id='id_site']/li/label")
client.waits.forPageLoad(timeout=u'20000')
client.click(id=u'id_site_0')
client.radio(id=u'id_site_0')
client.click(id=u'id_old_path')
client.type(text=u'/events/test', id=u'id_old_path')
client.type(text=u'/', id=u'id_new_path')
client.type(text=u'/test_admin/', id=u'id_new_path')
client.click(id=u'id_new_path')
client.doubleClick(id=u'id_new_path')
client.type(text=u'/testflat/test/', id=u'id_new_path')
client.click(name=u'_save')
client.waits.forPageLoad(timeout=u'20000')
client.click(link=u'/events/test')
client.waits.forPageLoad(timeout=u'20000')
client.click(link=u'Home')
client.waits.forPageLoad(timeout=u'20000')
client.open(url=u'http://localhost:8000/events/test')
client.waits.forPageLoad(timeout=u'8000')
client.asserts.assertText(xpath=u'/html/body', validator=u'This is some unique test content. ')
client.open(url=u'http://localhost:8000/test_admin/admin/')
client.waits.forPageLoad(timeout=u'8000')

View File

@ -170,9 +170,16 @@ def django_tests(verbosity, interactive, test_labels):
#'from .* import .*', 'import .*', ]
settings.COVERAGE_ADDITIONAL_MODULES = ['django']
# 'from .* import .*', 'import .*',
test_runner = get_runner(settings, coverage=True, reports=True)
tr = test_runner()
failures = tr.run_tests(test_labels, verbosity=verbosity, interactive=interactive, extra_tests=extra_tests)
if(do_std):
if(do_coverage):
test_runner = get_runner(settings, coverage=True, reports=True)
else:
test_runner = get_runner(settings, coverage=False, reports=False)
if(type(test_runner) == 'function'):
failures = test_runner(test_labels, verbosity=verbosity, interactive=interactive, extra_tests=extra_tests)
else:
tr = test_runner()
failures = tr.run_tests(test_labels, verbosity=verbosity, interactive=interactive, extra_tests=extra_tests)
#from windmill.authoring import djangotest
from time import sleep
@ -191,9 +198,15 @@ def django_tests(verbosity, interactive, test_labels):
# print cache.app_store
# m = cache.app_models['invalid_models']
# print m
mod = import_module('.models','modeltests.invalid_models')
del cache.app_store[mod]
del cache.app_models['invalid_models']
if(do_std):
mod = import_module('.models','modeltests.invalid_models')
try:
del cache.app_store[mod]
del cache.app_models['invalid_models']
except Exception, e:
print e
pass
# print cache.app_models
@ -291,7 +304,9 @@ def django_tests(verbosity, interactive, test_labels):
settings.LOGIN_URL = old_login_url
settings.MIDDLEWARE_CLASSES = old_middleware_classes
global do_windmill
# global do_windmill
# global do_coverage
# global do_std
if __name__ == "__main__":
from optparse import OptionParser
usage = "%prog [options] [model model model ...]"
@ -303,6 +318,10 @@ if __name__ == "__main__":
help='Tells Django to NOT prompt the user for input of any kind.')
parser.add_option('--windmill', action='store_true', dest='windmill', default=False,
help='Tells Django to run the Windmill functional tests as well.')
parser.add_option('--coverage', action='store_true', dest='coverage', default=False,
help='Tells Django to run the tests with code coverage as well.')
parser.add_option('--nostd', action='store_false', dest='standard', default=True,
help='Tells Django to not run the standard regression suite.')
parser.add_option('--settings',
help='Python path to settings module, e.g. "myproject.settings". If this isn\'t provided, the DJANGO_SETTINGS_MODULE environment variable will be used.')
options, args = parser.parse_args()
@ -312,4 +331,6 @@ if __name__ == "__main__":
parser.error("DJANGO_SETTINGS_MODULE is not set in the environment. "
"Set it or use --settings.")
do_windmill = options.windmill
do_coverage = options.coverage
do_std = options.standard
django_tests(int(options.verbosity), options.interactive, args)

View File

@ -0,0 +1,10 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
<title>{{ flatpage.title }}</title>
</head>
<body>
{{ flatpage.content }}
</body>
</html>