summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--django/conf/global_settings.py2
-rw-r--r--django/core/management/commands/test_windmill.py10
-rw-r--r--django/test/test_coverage.py13
-rw-r--r--django/test/windmill_tests.py123
-rw-r--r--django/utils/module_tools/__init__.py16
-rw-r--r--tests/regressiontests/admin_views/tests.py21
-rw-r--r--tests/regressiontests/admin_views/windmilltests/__init__.py346
-rwxr-xr-xtests/runtests.py166
8 files changed, 605 insertions, 92 deletions
diff --git a/django/conf/global_settings.py b/django/conf/global_settings.py
index 431b5208b8..eb9629990d 100644
--- a/django/conf/global_settings.py
+++ b/django/conf/global_settings.py
@@ -398,7 +398,7 @@ TEST_DATABASE_COLLATION = None
# Specify the coverage test runner
-COVERAGE_TEST_RUNNER = 'django.test.test_coverage.BaseCoverageRunner'
+COVERAGE_TEST_RUNNER = 'django.test.test_coverage.ConsoleReportCoverageRunner'
# Specify regular expressions of code blocks the coverage analyzer should
# ignore as statements (e.g. ``raise NotImplemented``).
diff --git a/django/core/management/commands/test_windmill.py b/django/core/management/commands/test_windmill.py
index d9b72f9c3e..406083c739 100644
--- a/django/core/management/commands/test_windmill.py
+++ b/django/core/management/commands/test_windmill.py
@@ -1,5 +1,6 @@
from django.core.management.base import BaseCommand
-from windmill.authoring import djangotest
+#from windmill.authoring import djangotest
+from django.test import windmill_tests as djangotest
import sys, os
from time import sleep
import types
@@ -18,7 +19,10 @@ def attempt_import(name, suffix):
s = name.split('.')
mod = __import__(s.pop(0))
for x in s+[suffix]:
- mod = getattr(mod, x)
+ try:
+ mod = getattr(mod, x)
+ except Exception, e:
+ pass
return mod
class Command(BaseCommand):
@@ -31,7 +35,7 @@ class Command(BaseCommand):
def handle(self, *labels, **options):
from windmill.conf import global_settings
- from windmill.authoring.djangotest import WindmillDjangoUnitTest
+ from django.test.windmill_tests import WindmillDjangoUnitTest
if 'ie' in labels:
global_settings.START_IE = True
sys.argv.remove('ie')
diff --git a/django/test/test_coverage.py b/django/test/test_coverage.py
index cf35795ee5..f6cf0312ac 100644
--- a/django/test/test_coverage.py
+++ b/django/test/test_coverage.py
@@ -63,6 +63,15 @@ class BaseCoverageRunner(object):
coverage_modules, getattr(settings, 'COVERAGE_MODULE_EXCLUDES', []),
getattr(settings, 'COVERAGE_PATH_EXCLUDES', []))
+
+
+ return results
+
+class ConsoleReportCoverageRunner(BaseCoverageRunner):
+
+ def run_tests(self, *args, **kwargs):
+ """docstring for run_tests"""
+ res = super(ConsoleReportCoverageRunner, self).run_tests( *args, **kwargs)
self.cov.report(self.modules.values(), show_missing=1)
if self.excludes:
@@ -77,9 +86,7 @@ class BaseCoverageRunner(object):
for e in self.errors:
print >> sys.stderr, e,
print >> sys.stdout
-
- return results
-
+ return res
class ReportingCoverageRunner(BaseCoverageRunner):
"""Runs coverage.py analysis, as well as generating detailed HTML reports."""
diff --git a/django/test/windmill_tests.py b/django/test/windmill_tests.py
new file mode 100644
index 0000000000..569f13a014
--- /dev/null
+++ b/django/test/windmill_tests.py
@@ -0,0 +1,123 @@
+
+# Code from django_live_server_r8458.diff @ http://code.djangoproject.com/ticket/2879#comment:41
+# Editing to monkey patch django rather than be in trunk
+
+import socket
+import threading
+from django.core.handlers.wsgi import WSGIHandler
+from django.core.servers import basehttp
+from django.test.testcases import call_command
+
+#from django.core.management import call_command
+
+# support both django 1.0 and 1.1
+try:
+ from django.test.testcases import TransactionTestCase as TestCase
+except ImportError:
+ from django.test.testcases import TestCase
+
+class StoppableWSGIServer(basehttp.WSGIServer):
+ """WSGIServer with short timeout, so that server thread can stop this server."""
+
+ def server_bind(self):
+ """Sets timeout to 1 second."""
+ basehttp.WSGIServer.server_bind(self)
+ self.socket.settimeout(1)
+
+ def get_request(self):
+ """Checks for timeout when getting request."""
+ try:
+ sock, address = self.socket.accept()
+ sock.settimeout(None)
+ return (sock, address)
+ except socket.timeout:
+ raise
+
+class TestServerThread(threading.Thread):
+ """Thread for running a http server while tests are running."""
+
+ def __init__(self, address, port):
+ self.address = address
+ self.port = port
+ self._stopevent = threading.Event()
+ self.started = threading.Event()
+ self.error = None
+ super(TestServerThread, self).__init__()
+
+ def run(self):
+ """Sets up test server and database and loops over handling http requests."""
+ try:
+ handler = basehttp.AdminMediaHandler(WSGIHandler())
+ httpd = None
+ while httpd is None:
+ try:
+ server_address = (self.address, self.port)
+ httpd = StoppableWSGIServer(server_address, basehttp.WSGIRequestHandler)
+ except basehttp.WSGIServerException, e:
+ if "Address already in use" in str(e):
+ self.port +=1
+ else:
+ raise e
+ httpd.set_app(handler)
+ self.started.set()
+ except basehttp.WSGIServerException, e:
+ self.error = e
+ self.started.set()
+ return
+
+ # Must do database stuff in this new thread if database in memory.
+ from django.conf import settings
+ if settings.DATABASE_ENGINE == 'sqlite3' \
+ and (not settings.TEST_DATABASE_NAME or settings.TEST_DATABASE_NAME == ':memory:'):
+ from django.db import connection
+ db_name = connection.creation.create_test_db(0)
+ # Import the fixture data into the test database.
+ if hasattr(self, 'fixtures'):
+ # We have to use this slightly awkward syntax due to the fact
+ # that we're using *args and **kwargs together.
+ call_command('loaddata', *self.fixtures, **{'verbosity': 0})
+
+ # Loop until we get a stop event.
+ while not self._stopevent.isSet():
+ httpd.handle_request()
+ httpd.server_close()
+
+ def join(self, timeout=None):
+ """Stop the thread and wait for it to finish."""
+ self._stopevent.set()
+ threading.Thread.join(self, timeout)
+
+
+def start_test_server(self, address='localhost', port=8000):
+ """Creates a live test server object (instance of WSGIServer)."""
+ self.server_thread = TestServerThread(address, port)
+ if hasattr(self, 'fixtures'):
+ self.server_thread.__setattr__('fixtures', self.fixtures)
+ self.server_thread.start()
+ self.server_thread.started.wait()
+ if self.server_thread.error:
+ raise self.server_thread.error
+
+def stop_test_server(self):
+ if self.server_thread:
+ self.server_thread.join()
+
+## New Code
+
+TestCase.start_test_server = classmethod(start_test_server)
+TestCase.stop_test_server = classmethod(stop_test_server)
+
+from windmill.authoring import unit
+
+class WindmillDjangoUnitTest(TestCase, unit.WindmillUnitTestCase):
+ test_port = 8000
+ def setUp(self):
+ self.start_test_server('localhost', self.test_port)
+ self.test_url = 'http://localhost:%d' % self.server_thread.port
+ unit.WindmillUnitTestCase.setUp(self)
+
+ def tearDown(self):
+ unit.WindmillUnitTestCase.tearDown(self)
+ self.stop_test_server()
+
+WindmillDjangoTransactionUnitTest = WindmillDjangoUnitTest
diff --git a/django/utils/module_tools/__init__.py b/django/utils/module_tools/__init__.py
index d940906d2d..976d4b5e4f 100644
--- a/django/utils/module_tools/__init__.py
+++ b/django/utils/module_tools/__init__.py
@@ -1,19 +1,3 @@
-"""
-Copyright 2009 55 Minutes (http://www.55minutes.com)
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-"""
-
from module_loader import *
from module_walker import *
diff --git a/tests/regressiontests/admin_views/tests.py b/tests/regressiontests/admin_views/tests.py
index 8e7010be9f..769bc9a759 100644
--- a/tests/regressiontests/admin_views/tests.py
+++ b/tests/regressiontests/admin_views/tests.py
@@ -1419,3 +1419,24 @@ class AdminInlineTests(TestCase):
self.failUnlessEqual(response.status_code, 302)
self.failUnlessEqual(FancyDoodad.objects.count(), 1)
self.failUnlessEqual(FancyDoodad.objects.all()[0].name, "Fancy Doodad 1 Updated")
+
+import os
+from django.test import windmill_tests as djangotest
+#from windmill.authoring import djangotest
+from windmill.conf import global_settings
+
+# class TestProjectWindmillTest(djangotest.WindmillDjangoUnitTest):
+# fixtures = ['admin-views-users.xml', 'admin-views-colors.xml', 'admin-views-fabrics.xml', 'admin-views-unicode.xml',
+# 'multiple-child-classes', 'admin-views-actions.xml', 'string-primary-key.xml', 'admin-views-person.xml']
+# test_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'windmilltests')
+# #test_dir = os.path.dirname(os.path.abspath(__file__))
+# #test_dir = os.path.dirname(os.path.abspath(__file__))
+# browser = 'firefox'
+# test_url = 'http://localhost:8000/test_admin/admin/'
+# global_settings.TEST_URL = test_url
+
+ # def test_tryout(self):
+ # pass
+
+
+
diff --git a/tests/regressiontests/admin_views/windmilltests/__init__.py b/tests/regressiontests/admin_views/windmilltests/__init__.py
new file mode 100644
index 0000000000..1b1e60b882
--- /dev/null
+++ b/tests/regressiontests/admin_views/windmilltests/__init__.py
@@ -0,0 +1,346 @@
+# import os
+# from django.test import windmill_tests as djangotest
+# #from windmill.authoring import djangotest
+# from windmill.conf import global_settings
+#
+# class TestProjectWindmillTest(djangotest.WindmillDjangoUnitTest):
+# fixtures = ['admin-views-users.xml', 'admin-views-colors.xml', 'admin-views-fabrics.xml', 'admin-views-unicode.xml',
+# 'multiple-child-classes', 'admin-views-actions.xml', 'string-primary-key.xml', 'admin-views-person.xml']
+# #test_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'windmilltests')
+# test_dir = os.path.dirname(os.path.abspath(__file__))
+# #test_dir = os.path.dirname(os.path.abspath(__file__))
+# browser = 'firefox'
+# test_url = 'http://localhost:8000/test_admin/admin/'
+# global_settings.TEST_URL = test_url
+#
+# # def test_tryout(self):
+# # pass
+#
+
+# Generated by the windmill services transformer
+from windmill.authoring import WindmillTestClient
+
+# def test_recordingSuite0():
+# client = WindmillTestClient(__name__)
+# client.open("http://localhost:8000/test_admin/admin")
+# client.type(text="Hello", name='q')
+# client.click(xpath=u"//span[@id='body']/center/form/table[2]/tbody/tr[8]/td")
+# client.waits.forPageLoad(timeout=u'20000')
+# client.asserts.assertNode(xpath=u"//div[@id='res']/div/ol/li/h3[1]/a/em")
+# client.asserts.assertNode(link=u'How do you say hello in Japanese ? - Yahoo! Answers')
+# client.asserts.assertNode(link=u'hello')
+# client.asserts.assertNode(link=u'japanese')
+#
+
+
+def test_recordingSuite1():
+ '''Mostly just a proof of concept to test working order of tests.'''
+ client = WindmillTestClient(__name__)
+
+ # print dir(client)
+ # print dir(client.open)
+ # print dir(client.commands)
+ # print client.commands()
+
+ client.open(url="http://localhost:8000/test_admin/admin")
+ client.type(text=u'super', id=u'id_username')
+ client.type(text=u'secret', id=u'id_password')
+ client.click(value=u'Log in')
+ client.waits.forPageLoad(timeout=u'20000')
+ client.asserts.assertNode(xpath=u"//div[@id='content-main']/div/table/tbody/tr[1]/th")
+ client.asserts.assertNode(link=u'Articles')
+ client.asserts.assertNode(link=u'Add')
+ client.asserts.assertNode(link=u'Change')
+ client.asserts.assertNode(link=u'Admin_Views')
+ client.asserts.assertNode(xpath=u"//div[@id='user-tools']/strong")
+ client.click(xpath=u"//div[@id='content-main']/div/table/tbody/tr[22]/td/a")
+ client.waits.forPageLoad(timeout=u'20000')
+ client.type(text=u'Test Section', id=u'id_name')
+ client.click(name=u'_save')
+ client.waits.forPageLoad(timeout=u'20000')
+ client.asserts.assertNode(link=u'Section object')
+ client.click(link=u' Admin_views ')
+ client.waits.forPageLoad(timeout=u'20000')
+ client.waits.forElement(link=u'Add', timeout=u'8000')
+ client.click(link=u'Add')
+ client.waits.forPageLoad(timeout=u'20000')
+ client.type(text=u'Test 1', id=u'id_title')
+ client.type(text=u'This is test content.', id=u'id_content')
+ client.click(link=u'Today')
+ client.click(link=u'Now')
+ client.click(id=u'id_section')
+ client.select(option=u'Section object', id=u'id_section')
+ client.click(value=u'1')
+ #client.asserts.assertValue(validator=u'2009-06-16', id=u'id_date_0')
+ #client.asserts.assertValue(validator=u'13:31:21', id=u'id_date_1')
+ client.asserts.assertNode(id=u'id_section')
+ client.click(name=u'_save')
+ client.waits.forPageLoad(timeout=u'20000')
+ client.asserts.assertNode(link=u'This is test content.')
+ client.asserts.assertNode(xpath=u"//div[@id='changelist']/form/table/tbody/tr/td[2]")
+ client.asserts.assertNode(xpath=u"//div[@id='changelist']/form/table/tbody/tr/td[3]")
+ client.asserts.assertNode(xpath=u"//div[@id='changelist']/form/table/tbody/tr/td[4]")
+ client.asserts.assertNode(xpath=u"//div[@id='changelist']/form/table/tbody/tr/td[5]")
+ client.asserts.assertNode(xpath=u"//div[@id='changelist']/form/table/tbody/tr/th")
+ client.click(link=u'Today')
+ client.waits.forPageLoad(timeout=u'20000')
+ client.asserts.assertNode(xpath=u"//div[@id='changelist']/form/table/tbody/tr/th")
+ client.click(link=u' Home ')
+ client.waits.forPageLoad(timeout=u'20000')
+
+def test_recordingSuite2():
+ '''Creating a Model with strings for pk, and checking history.'''
+ client = WindmillTestClient(__name__)
+ client.open(url="http://localhost:8000/test_admin/admin")
+ client.waits.forPageLoad(timeout=u'20000')
+ # client.open(url="http://localhost:8000/test_admin/admin")
+ # client.type(text=u'super', id=u'id_username')
+ # client.type(text=u'secret', id=u'id_password')
+ # client.waits.forPageLoad(timeout=u'20000')
+ client.waits.forElement(link=u'Model with string primary keys', timeout=u'8000')
+ client.click(link=u'Model with string primary keys')
+ client.waits.forPageLoad(timeout=u'20000')
+ client.click(link=u' Add model with string primary key ')
+ client.waits.forPageLoad(timeout=u'20000')
+ client.type(text=u'hello', id=u'id_id')
+ client.click(name=u'_save')
+ client.waits.forPageLoad(timeout=u'20000')
+ #client.asserts.assertNode(link=u'hello')
+ client.click(link=u'hello')
+ client.waits.forPageLoad(timeout=u'20000')
+ client.click(link=u'History')
+ client.waits.forPageLoad(timeout=u'20000')
+ client.asserts.assertNode(xpath=u"//table[@id='change-history']/tbody/tr/td")
+ client.click(link=u'hello')
+ client.waits.forPageLoad(timeout=u'20000')
+ client.asserts.assertValue(validator=u'hello', id=u'id_id')
+ client.click(link=u'Delete')
+ client.waits.forPageLoad(timeout=u'20000')
+ client.asserts.assertNode(xpath=u"//div[@id='content']/ul/li")
+ client.asserts.assertNode(link=u'hello')
+ client.click(value=u"Yes, I'm sure")
+ client.waits.forPageLoad(timeout=u'20000')
+ client.asserts.assertText(xpath=u"//div[@id='changelist']/form/p", validator=u'\n\n1 model with string primary key\n\n\n')
+ client.click(link=u' Home ')
+
+def test_recordingSuite3():
+ '''Testing Updates and Filters/Search on Person Models'''
+ client = WindmillTestClient(__name__)
+
+ client.open(url="http://localhost:8000/test_admin/admin")
+ client.waits.forPageLoad(timeout=u'20000')
+ client.click(link=u'Persons')
+ client.asserts.assertNode(link=u'John Mauchly')
+ client.asserts.assertNode(link=u'Grace Hooper')
+ client.asserts.assertNode(link=u'Guido van Rossum')
+ client.asserts.assertSelected(validator=u'Male', id=u'id_form-0-gender')
+ client.asserts.assertValue(validator=u'1', id=u'id_form-1-gender')
+ client.asserts.assertSelected(validator=u'Male', id=u'id_form-2-gender')
+ client.asserts.assertValue(validator=u'on', id=u'id_form-0-alive')
+ client.asserts.assertValue(validator=u'on', id=u'id_form-1-alive')
+ client.asserts.assertValue(validator=u'on', id=u'id_form-2-alive')
+ client.click(link=u'John Mauchly')
+ client.asserts.assertValue(validator=u'John Mauchly', id=u'id_name')
+ client.asserts.assertSelected(validator=u'Male', id=u'id_gender')
+ client.asserts.assertValue(validator=u'on', id=u'id_alive')
+ client.check(id=u'id_alive')
+ client.click(xpath=u"//form[@id='person_form']/div/fieldset/div[2]")
+ client.click(id=u'id_gender')
+ client.select(option=u'Female', id=u'id_gender')
+ client.click(value=u'2')
+ client.click(id=u'id_name')
+ client.type(text=u'John Mauchly Updated', id=u'id_name')
+ client.click(name=u'_save')
+ client.asserts.assertSelected(validator=u'Female', id=u'id_form-0-gender')
+ client.asserts.assertValue(validator=u'on', id=u'id_form-0-alive')
+ client.asserts.assertNode(link=u'John Mauchly Updated')
+ client.click(id=u'searchbar')
+ client.type(text=u'John', id=u'searchbar')
+ client.click(value=u'Search')
+ client.asserts.assertNode(link=u'John Mauchly Updated')
+ client.click(link=u'3 total')
+ client.type(text=u'Grace', id=u'searchbar')
+ client.click(value=u'Search')
+ client.asserts.assertNode(link=u'Grace Hooper')
+ client.click(link=u'3 total')
+ client.asserts.assertNode(link=u'Guido van Rossum')
+ client.click(link=u'Female')
+ client.asserts.assertNode(link=u'John Mauchly Updated')
+ client.click(link=u'All')
+ client.asserts.assertNode(link=u'Guido van Rossum')
+ client.click(link=u' Home ')
+
+def test_recordingSuite4():
+ '''Admin Actions test. Test the default delete action.'''
+ client = WindmillTestClient(__name__)
+
+ client.open(url="http://localhost:8000/test_admin/admin")
+ client.waits.forPageLoad(timeout=u'20000')
+ client.click(link=u'Fabrics')
+ client.check(name=u'_selected_action')
+ client.click(name=u'action')
+ client.select(option=u'Delete selected fabrics', name=u'action')
+ client.click(value=u'delete_selected')
+ client.click(name=u'index')
+ client.click(value=u"Yes, I'm sure")
+ client.asserts.assertNode(link=u'Vertical')
+ client.asserts.assertNode(link=u'Horizontal')
+
+def test_recordingSuite5():
+ client = WindmillTestClient(__name__)
+
+ client.open(url="http://localhost:8000/test_admin/admin")
+ client.waits.forPageLoad(timeout=u'20000')
+ client.click(link=u'Articles')
+ client.waits.forPageLoad(timeout=u'20000')
+ client.waits.forElement(link=u'Date', timeout=u'8000')
+ client.click(link=u'Date')
+ client.waits.forPageLoad(timeout=u'20000')
+ client.asserts.assertText(xpath=u"//div[@id='changelist']/form/table/tbody/tr/td[2]", validator=u'March 18, 2000, 11:54 a.m.')
+ client.asserts.assertText(xpath=u"//div[@id='changelist']/form/table/tbody/tr[2]/td[2]", validator=u'March 18, 2008, 11:54 a.m.')
+ client.asserts.assertText(xpath=u"//div[@id='changelist']/form/table/tbody/tr/td[4]", validator=u'2000')
+ client.asserts.assertText(xpath=u"//div[@id='changelist']/form/table/tbody/tr[2]/td[4]", validator=u'2008')
+ client.asserts.assertText(xpath=u"//div[@id='changelist']/form/table/tbody/tr[3]/td[4]", validator=u'2009')
+ client.click(link=u'Modeladmin year')
+ client.waits.forPageLoad(timeout=u'20000')
+ client.waits.forElement(link=u'Content', timeout=u'8000')
+ client.click(link=u'Content')
+ client.waits.forPageLoad(timeout=u'20000')
+ client.asserts.assertText(xpath=u"//div[@id='changelist']/form/table/tbody/tr/td[4]", validator=u'2008')
+ client.click(xpath=u"//div[@id='changelist']/form/table/tbody/tr/th/a")
+ client.waits.forPageLoad(timeout=u'20000')
+ client.waits.forElement(xpath=u"//a[@id='calendarlink0']/img", timeout=u'8000')
+ client.click(xpath=u"//a[@id='calendarlink0']/img")
+ client.click(link=u'Cancel')
+ client.click(xpath=u"//a[@id='clocklink0']/img")
+ client.click(link=u'Midnight')
+ client.click(id=u'id_date_1')
+ client.asserts.assertValue(validator=u'00:00:00', id=u'id_date_1')
+ client.click(xpath=u"//a[@id='clocklink0']/img")
+ client.click(link=u'6 a.m.')
+ client.asserts.assertValue(validator=u'06:00:00', id=u'id_date_1')
+ client.click(xpath=u"//a[@id='clocklink0']/img")
+ client.click(link=u'Noon')
+ client.click(id=u'id_date_1')
+ client.asserts.assertValue(validator=u'12:00:00', id=u'id_date_1')
+ client.click(link=u'Articles')
+ client.waits.forPageLoad(timeout=u'20000')
+ client.waits.forElement(link=u' Add article ', timeout=u'8000')
+ client.click(link=u' Add article ')
+ client.waits.forPageLoad(timeout=u'20000')
+ client.type(text=u'Test Art', id=u'id_title')
+ client.type(text=u'<p> Test </p>', id=u'id_content')
+ client.click(xpath=u"//a[@id='calendarlink0']/img")
+ client.click(link=u'17')
+ client.click(xpath=u"//a[@id='clocklink0']/img")
+ client.click(link=u'6 a.m.')
+ client.click(id=u'id_section')
+ client.select(option=u'Section object', id=u'id_section')
+ client.click(value=u'1')
+ client.click(name=u'_save')
+ client.waits.forPageLoad(timeout=u'20000')
+ client.waits.forElement(xpath=u"//div[@id='changelist']/form/table/tbody/tr/th/a", timeout=u'8000')
+ client.click(xpath=u"//div[@id='changelist']/form/table/tbody/tr/th/a")
+ client.waits.forPageLoad(timeout=u'20000')
+ client.waits.forElement(timeout=u'8000', id=u'id_content')
+ client.click(id=u'id_content')
+ client.type(text=u'<p> Test This </p>', id=u'id_content')
+ client.click(name=u'_continue')
+ client.waits.forPageLoad(timeout=u'20000')
+ client.asserts.assertValue(validator=u'<p> Test This </p>', id=u'id_content')
+ client.click(link=u'Articles')
+ client.waits.forPageLoad(timeout=u'20000')
+ client.check(name=u'_selected_action')
+ client.click(name=u'action')
+ client.check(name=u'_selected_action')
+ client.click(link=u' Home ')
+ client.waits.forPageLoad(timeout=u'20000')
+
+def test_recordingSuite6():
+ client = WindmillTestClient(__name__)
+
+ client.open(url="http://localhost:8000/test_admin/admin")
+ client.waits.forPageLoad(timeout=u'20000')
+ client.click(link=u'Parents')
+ client.waits.forPageLoad(timeout=u'20000')
+ client.waits.forElement(link=u' Add parent ', timeout=u'8000')
+ client.click(link=u' Add parent ')
+ client.waits.forPageLoad(timeout=u'20000')
+ client.type(text=u'Papa', id=u'id_name')
+ client.type(text=u'Billy', id=u'id_child_set-0-name')
+ client.type(text=u'Bobby', id=u'id_child_set-1-name')
+ client.type(text=u'Betty', id=u'id_child_set-2-name')
+ client.click(name=u'_save')
+ client.waits.forPageLoad(timeout=u'20000')
+ client.waits.forElement(link=u'Parent object', timeout=u'8000')
+ client.click(link=u'Parent object')
+ client.waits.forPageLoad(timeout=u'20000')
+ client.asserts.assertValue(validator=u'Billy', id=u'id_child_set-0-name')
+ client.asserts.assertValue(validator=u'Bobby', id=u'id_child_set-1-name')
+ client.asserts.assertValue(validator=u'Betty', id=u'id_child_set-2-name')
+ client.click(link=u'Home')
+ client.waits.forPageLoad(timeout=u'20000')
+
+
+def test_recordingSuite7():
+ client = WindmillTestClient(__name__)
+
+ client.open(url="http://localhost:8000/test_admin/admin")
+ client.waits.forPageLoad(timeout=u'20000')
+ client.click(link=u'Empty models')
+ client.waits.forPageLoad(timeout=u'20000')
+ client.waits.forElement(link=u' Add empty model ', timeout=u'8000')
+ client.click(link=u' Add empty model ')
+ client.waits.forPageLoad(timeout=u'20000')
+ client.waits.forElement(timeout=u'8000', name=u'_save')
+ client.click(name=u'_save')
+ client.waits.forPageLoad(timeout=u'20000')
+ client.waits.forElement(link=u' Add empty model ', timeout=u'8000')
+ client.click(link=u' Add empty model ')
+ client.waits.forPageLoad(timeout=u'20000')
+ client.waits.forElement(timeout=u'8000', name=u'_continue')
+ client.click(name=u'_continue')
+ client.waits.forPageLoad(timeout=u'20000')
+ client.waits.forElement(link=u'Empty models', timeout=u'8000')
+ client.click(link=u'Empty models')
+ client.waits.forPageLoad(timeout=u'20000')
+ client.waits.forElement(link=u'Primary key = 2', timeout=u'8000')
+ client.click(link=u'Primary key = 2')
+ client.waits.forPageLoad(timeout=u'20000')
+ client.waits.forElement(timeout=u'8000', name=u'_addanother')
+ client.click(name=u'_addanother')
+ client.waits.forPageLoad(timeout=u'20000')
+ client.waits.forElement(timeout=u'8000', name=u'_save')
+ client.click(name=u'_save')
+ client.waits.forPageLoad(timeout=u'20000')
+ client.waits.forElement(link=u'Primary key = 3', timeout=u'8000')
+ client.click(link=u'Primary key = 3')
+ client.waits.forPageLoad(timeout=u'20000')
+ client.waits.forElement(timeout=u'8000', name=u'_addanother')
+ client.click(name=u'_addanother')
+ client.waits.forPageLoad(timeout=u'20000')
+ client.waits.forElement(timeout=u'8000', name=u'_save')
+ client.click(name=u'_save')
+ client.waits.forPageLoad(timeout=u'20000')
+ client.check(xpath=u"//div[@id='changelist']/form/table/tbody/tr[2]/td[1]/input")
+ client.check(name=u'_selected_action')
+ client.click(name=u'action')
+ client.select(option=u'Delete selected empty models', name=u'action')
+ client.click(value=u'delete_selected')
+ client.click(name=u'index')
+ client.waits.forPageLoad(timeout=u'20000')
+ client.waits.forElement(timeout=u'8000', value=u"Yes, I'm sure")
+ client.click(value=u"Yes, I'm sure")
+ client.waits.forPageLoad(timeout=u'20000')
+ client.waits.forElement(link=u'Primary key = 2', timeout=u'8000')
+ client.click(link=u'Primary key = 2')
+ client.waits.forPageLoad(timeout=u'20000')
+ client.waits.forElement(link=u'Delete', timeout=u'8000')
+ client.click(link=u'Delete')
+ client.waits.forPageLoad(timeout=u'20000')
+ client.waits.forElement(timeout=u'8000', value=u"Yes, I'm sure")
+ client.click(value=u"Yes, I'm sure")
+ 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') \ No newline at end of file
diff --git a/tests/runtests.py b/tests/runtests.py
index 982293c7f0..fa2f8b5e7b 100755
--- a/tests/runtests.py
+++ b/tests/runtests.py
@@ -4,7 +4,9 @@ import os, sys, traceback
import unittest
import coverage
import django.contrib as contrib
+from django.core.servers import basehttp
+import django
try:
set
except NameError:
@@ -30,9 +32,11 @@ ALWAYS_INSTALLED_APPS = [
'django.contrib.sessions',
'django.contrib.comments',
'django.contrib.admin',
- 'windmill',
]
+
+ALWAYS_INSTALLED_APPS.extend(('%s.%s' % (REGRESSION_TESTS_DIR_NAME,a) for a in os.listdir(REGRESSION_TEST_DIR) if not('.py' in a or '.svn' in a) ))
+
def get_test_models():
models = []
for loc, dirpath in (MODEL_TESTS_DIR_NAME, MODEL_TEST_DIR), (REGRESSION_TESTS_DIR_NAME, REGRESSION_TEST_DIR), (CONTRIB_DIR_NAME, CONTRIB_DIR):
@@ -89,6 +93,7 @@ class InvalidModelTestCase(unittest.TestCase):
def django_tests(verbosity, interactive, test_labels):
from django.conf import settings
+
old_installed_apps = settings.INSTALLED_APPS
old_test_database_name = settings.TEST_DATABASE_NAME
old_root_urlconf = getattr(settings, "ROOT_URLCONF", "")
@@ -100,6 +105,8 @@ def django_tests(verbosity, interactive, test_labels):
# Redirect some settings for the duration of these tests.
settings.INSTALLED_APPS = ALWAYS_INSTALLED_APPS
+ if do_windmill:
+ settings.INSTALLED_APPS.append('windmill')
settings.ROOT_URLCONF = 'urls'
settings.TEMPLATE_DIRS = (os.path.join(os.path.dirname(__file__), TEST_TEMPLATE_DIR), )
settings.USE_I18N = True
@@ -165,83 +172,100 @@ def django_tests(verbosity, interactive, test_labels):
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)
- from django.core.management.commands.test_windmill import ServerContainer, attempt_import
- # as testwm_cmd
- # windmill_runner = testwm_cmd()
- # windmill_runner.handle()
+ #from windmill.authoring import djangotest
+ from time import sleep
+ if do_windmill:
- from windmill.conf import global_settings
- from windmill.authoring.djangotest import WindmillDjangoUnitTest
- # if 'ie' in labels:
- # global_settings.START_IE = True
- # sys.argv.remove('ie')
- # elif 'safari' in labels:
- # global_settings.START_SAFARI = True
- # sys.argv.remove('safari')
- # elif 'chrome' in labels:
- # global_settings.START_CHROME = True
- # sys.argv.remove('chrome')
- # else:
- global_settings.START_FIREFOX = True
- # if 'firefox' in labels:
- # sys.argv.remove('firefox')
+ #from django.test import windmill_tests as djangotest
+ import types
+ import logging
+ from windmill.conf import global_settings
+ from django.test.windmill_tests import WindmillDjangoUnitTest
+ from django.core.management.commands.test_windmill import ServerContainer, attempt_import
+ #from django.test import windmill_tests
+ # as testwm_cmd
+ # windmill_runner = testwm_cmd()
+ # windmill_runner.handle()
- # if 'manage.py' in sys.argv:
- # sys.argv.remove('manage.py')
- # if 'test_windmill' in sys.argv:
- # sys.argv.remove('test_windmill')
- server_container = ServerContainer()
- server_container.start_test_server()
- global_settings.TEST_URL = 'http://localhost:%d' % server_container.server_thread.port
- # import windmill
- # windmill.stdout, windmill.stdin = sys.stdout, sys.stdin
- from windmill.authoring import setup_module, teardown_module
+ # from windmill.authoring.djangotest import WindmillDjangoUnitTest
+ # if 'ie' in labels:
+ # global_settings.START_IE = True
+ # sys.argv.remove('ie')
+ # elif 'safari' in labels:
+ # global_settings.START_SAFARI = True
+ # sys.argv.remove('safari')
+ # elif 'chrome' in labels:
+ # global_settings.START_CHROME = True
+ # sys.argv.remove('chrome')
+ # else:
+ global_settings.START_FIREFOX = True
+ # if 'firefox' in labels:
+ # sys.argv.remove('firefox')
- # from django.conf import settings
- tests = []
- for name in settings.INSTALLED_APPS:
- for suffix in ['tests', 'wmtests', 'windmilltests']:
- x = attempt_import(name, suffix)
- if x is not None: tests.append((suffix,x,));
+ # if 'manage.py' in sys.argv:
+ # sys.argv.remove('manage.py')
+ # if 'test_windmill' in sys.argv:
+ # sys.argv.remove('test_windmill')
+ server_container = ServerContainer()
+ server_container.fixtures = ['admin-views-users.xml', 'admin-views-colors.xml', 'admin-views-fabrics.xml', 'admin-views-unicode.xml',
+ 'multiple-child-classes', 'admin-views-actions.xml', 'string-primary-key.xml', 'admin-views-person.xml']
+ server_container.start_test_server()
- wmtests = []
- for (ttype, mod,) in tests:
- if ttype == 'tests':
- for ucls in [getattr(mod, x) for x in dir(mod)
- if ( type(getattr(mod, x, None)) in (types.ClassType,
- types.TypeType) ) and
- issubclass(getattr(mod, x), WindmillDjangoUnitTest)
- ]:
- wmtests.append(ucls.test_dir)
+ global_settings.TEST_URL = 'http://localhost:%d' % server_container.server_thread.port
+
+ # import windmill
+ # windmill.stdout, windmill.stdin = sys.stdout, sys.stdin
+ from windmill.authoring import setup_module, teardown_module
+
+ # from django.conf import settings
+ tests = []
+ for name in settings.INSTALLED_APPS:
+ for suffix in ['tests', 'wmtests', 'windmilltests']:
+ x = attempt_import(name, suffix)
+ if x is not None: tests.append((suffix,x,));
+
+ wmtests = []
+ for (ttype, mod,) in tests:
+ if ttype == 'tests':
+ for ucls in [getattr(mod, x) for x in dir(mod)
+ if ( type(getattr(mod, x, None)) in (types.ClassType,
+ types.TypeType) ) and
+ issubclass(getattr(mod, x), WindmillDjangoUnitTest)
+ ]:
+ wmtests.append(ucls.test_dir)
- else:
- if mod.__file__.endswith('__init__.py') or mod.__file__.endswith('__init__.pyc'):
- wmtests.append(os.path.join(*os.path.split(os.path.abspath(mod.__file__))[:-1]))
else:
- wmtests.append(os.path.abspath(mod.__file__))
+ if mod.__file__.endswith('__init__.py') or mod.__file__.endswith('__init__.pyc'):
+ wmtests.append(os.path.join(*os.path.split(os.path.abspath(mod.__file__))[:-1]))
+ else:
+ wmtests.append(os.path.abspath(mod.__file__))
+
+
+ if len(wmtests) is 0:
+ print 'Sorry, no windmill tests found.'
+ else:
+ testtotals = {}
+ x = logging.getLogger()
+ x.setLevel(0)
+ from windmill.server.proxy import logger
+ from functest import bin
+ from functest import runner
+ runner.CLIRunner.final = classmethod(lambda self, totals: testtotals.update(totals) )
+ import windmill
+ setup_module(tests[0][1])
+ #sys.argv = sys.argv + wmtests
+ sys.argv = wmtests
+ bin.cli()
+ teardown_module(tests[0][1])
+ if testtotals['fail'] is not 0:
+ sleep(.5)
+ sys.exit(1)
+ if failures:
+ sleep(.5)
+ sys.exit(failures)
- if len(wmtests) is 0:
- print 'Sorry, no windmill tests found.'
- else:
- testtotals = {}
- x = logging.getLogger()
- x.setLevel(0)
- from windmill.server.proxy import logger
- from functest import bin
- from functest import runner
- runner.CLIRunner.final = classmethod(lambda self, totals: testtotals.update(totals) )
- import windmill
- setup_module(tests[0][1])
- sys.argv = sys.argv + wmtests
- bin.cli()
- teardown_module(tests[0][1])
- # if testtotals['fail'] is not 0:
- # sleep(.5)
- # sys.exit(1)
- if failures or testtotals['fail'] is not 0:
- sys.exit(failures + testtotals['fail'])
# Restore the old settings.
settings.INSTALLED_APPS = old_installed_apps
settings.ROOT_URLCONF = old_root_urlconf
@@ -251,6 +275,7 @@ def django_tests(verbosity, interactive, test_labels):
settings.LOGIN_URL = old_login_url
settings.MIDDLEWARE_CLASSES = old_middleware_classes
+global do_windmill
if __name__ == "__main__":
from optparse import OptionParser
usage = "%prog [options] [model model model ...]"
@@ -260,6 +285,8 @@ if __name__ == "__main__":
help='Verbosity level; 0=minimal output, 1=normal output, 2=all output')
parser.add_option('--noinput', action='store_false', dest='interactive', default=True,
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('--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()
@@ -268,4 +295,5 @@ if __name__ == "__main__":
elif "DJANGO_SETTINGS_MODULE" not in os.environ:
parser.error("DJANGO_SETTINGS_MODULE is not set in the environment. "
"Set it or use --settings.")
+ do_windmill = options.windmill
django_tests(int(options.verbosity), options.interactive, args)