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

[gsoc2009-testing] Adding exclusion rules to coverage. Restructuring windmill tests. Starting work on docs. Fixed import issues when running with coverage. Add per-test models to TransactionTests.

git-svn-id: http://code.djangoproject.com/svn/django/branches/soc2009/test-improvements@11141 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Kevin Kubasik 2009-07-01 10:40:09 +00:00
parent b5ea9f6ad5
commit 8cd4df145f
7 changed files with 566 additions and 523 deletions

View File

@ -230,11 +230,13 @@ class TransactionTestCase(unittest.TestCase):
def _test_model_setup(self):
if hasattr(self, 'test_models'):
print self.test_models
#print self.test_models
if self.__module__.endswith('tests'):
app_label = self.__module__.split('.')[:-1][-1]
app_path = '.'.join(self.__module__.split('.')[:-1])
else:
app_label = self.__module__.split('.')[:-2][-1]
app_path = '.'.join(self.__module__.split('.')[:-2])
from django.db.models.loading import cache
from django.utils import importlib
from django.db import models
@ -244,7 +246,7 @@ class TransactionTestCase(unittest.TestCase):
app_mods = cache.app_models[app_label]
for tm in self.test_models:
#print "importing %s " % tm
im = importlib.import_module(tm)
im = importlib.import_module(app_path + '.' + tm)
#cache.app_store[im] = len(cache.app_store)
#print "finding model classes"
mod_classes = [f for f in im.__dict__.values() if hasattr(f,'__bases__') and issubclass(f,models.Model)]
@ -302,11 +304,13 @@ class TransactionTestCase(unittest.TestCase):
def _test_model_teardown(self):
if hasattr(self, 'test_models'):
print self.test_models
#print self.test_models
if self.__module__.endswith('tests'):
app_label = self.__module__.split('.')[:-1][-1]
app_path = '.'.join(self.__module__.split('.')[:-1])
else:
app_label = self.__module__.split('.')[:-2][-1]
app_path = '.'.join(self.__module__.split('.')[:-2])
from django.db.models.loading import cache
from django.utils import importlib
from django.db import models
@ -327,10 +331,10 @@ class TransactionTestCase(unittest.TestCase):
cache.write_lock.acquire()
try:
app_mods = cache.app_models[app_label]
print app_mods
#print app_mods
for tm in self.test_models:
#print "importing %s " % tm
im = importlib.import_module(tm)
im = importlib.import_module(app_path + '.' + tm)
#cache.app_store[im] = len(cache.app_store)
#print "finding model classes"
mod_classes = [f for f in im.__dict__.values() if hasattr(f,'__bases__') and issubclass(f,models.Model)]

View File

@ -1,40 +1,38 @@
.. _howto-windmill-tests:
Writing a Functional Tests with Windmill
=======================================
========================================
.. currentmodule:: django.test
If you need to provide custom file storage -- a common example is storing files
on some remote system -- you can do so by defining a custom storage class.
You'll need to follow these steps:
If you need to test overall behaviors of your site, ajax widgets or rendered
html, then functional tests are the solution. Django includes support for the
popular `Windmill`_ framework. Writing a windmill test
is simple, following these steps:
#. Your custom storage system must be a subclass of
``django.core.files.storage.Storage``::
.. _Windmill: http://getwindmill.com
#. Your windmill tests must be their own module, named ``wmtests`` or ``windmilltests``.
from django.core.files.storage import Storage
class MyStorage(Storage):
#. Django must be able to run any function in the module without arguments.
::
from windmill.conf import global_settings
ADMIN_URL = "%s/test_admin/admin" % global_settings.TEST_URL
from windmill.authoring import WindmillTestClient
from django.test.utils import calling_func_name
def test_loginAndSetup():
'''Mostly just a proof of concept to test working order of tests.'''
client = WindmillTestClient(calling_func_name())
client.open(url='http://localhost:8000/admin')
client.waits.forPageLoad(timeout=u'20000')
...
#. Django must be able to instantiate your storage system without any arguments.
This means that any settings should be taken from ``django.conf.settings``::
from django.conf import settings
from django.core.files.storage import Storage
class MyStorage(Storage):
def __init__(self, option=None):
if not option:
option = settings.CUSTOM_STORAGE_OPTIONS
...
#. Your storage class must implement the ``_open()`` and ``_save()`` methods,
along with any other methods appropriate to your storage class. See below for
more on these methods.
In addition, if your class provides local file storage, it must override
the ``path()`` method.
#. Your windmill testing module must load any files other than the module loader
in ``__init__.py``.
::
from primary.py import *
Your custom storage system may override any of the storage methods explained in
:ref:`ref-files-storage`, but you **must** implement the following methods:

View File

@ -414,7 +414,7 @@ is why Django makes it easy to integrate with 3rd party test runners via the
:setting:`TEST_RUNNER` setting. For convenience, Django ships a runner for
the framework used in testing the :ref:`admin interface, <ref-contrib-admin>`
Windmill_. Details on integrating Windmill tests with Django are available
:ref:`here. <howto-windmill-test>`
:ref:`here. <howto-windmill-tests>`
.. _Twill: http://twill.idyll.org/
.. _Windmill: http://www.getwindmill.com/
@ -981,6 +981,8 @@ This flush/load procedure is repeated for each test in the test case, so you
can be certain that the outcome of a test will not be affected by another test,
or by the order of test execution.
.. _topics-testing-urlconf:
URLconf configuration
~~~~~~~~~~~~~~~~~~~~~
@ -1014,6 +1016,35 @@ For example::
This test case will use the contents of ``myapp.test_urls`` as the
URLconf for the duration of the test case.
.. _topics-testing-testmodels:
Test-Only Models configuration
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. versionadded:: 1.1
.. attribute:: TransactionTestCase.test_models
If you want to test your application with models that are only available during specific
test cases, ``django.test.TransactionTestCase`` provides the ability to customize the models
configuration for the duration of the execution of a test suite. If your
``TransactionTestCase`` instance defines an ``test_models`` attribute, the ``TransactionTestCase`` will load
the value of that attribute as a module, and load the models contained within for the
duration of that test.
For example::
from django.test import TransactionTestCase
class TestMyViews(TransactionTestCase):
test_models = ['test_models']
def testIndexPageView(self):
# Here you'd test your view using ``Client``.
This test case will load the contents of ``myapp.test_models`` and add
any subclass of ``django.db.models.Model`` to ``myapp.models``.
.. _emptying-test-outbox:
Emptying the test outbox

View File

@ -27,7 +27,7 @@ except NameError:
class AdminViewBasicTest(TestCase):
fixtures = ['admin-views-users.xml', 'admin-views-colors.xml', 'admin-views-fabrics.xml']
test_models = ['regressiontests.admin_views.test_models']
test_models = ['test_models']
# Store the bit of the URL where the admin is registered as a class
# variable. That way we can test a second AdminSite just by subclassing
# this test case and changing urlbit.

View File

@ -36,491 +36,4 @@ from django.test.utils import calling_func_name
# import functest
# functest.modules_passed = []
# functest.modules_failed = []
def test_loginAndSetup():
'''Mostly just a proof of concept to test working order of tests.'''
client = WindmillTestClient(calling_func_name())
# print dir(client)
# print dir(client.open)
# print dir(client.commands)
# print client.commands()
client.open(url=ADMIN_URL)
client.waits.forPageLoad(timeout=u'20000')
client.open(url=ADMIN_URL)
client.waits.forPageLoad(timeout=u'20000')
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_changeListNamingLinkingHistory():
'''Creating a Model with strings for pk, and checking history.'''
client = WindmillTestClient(calling_func_name())
client.open(url=ADMIN_URL)
client.waits.forPageLoad(timeout=u'20000')
# client.open(url=ADMIN_URL)
# 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_filtersSearchOnChangeList():
'''Testing Updates and Filters/Search on Person Models'''
client = WindmillTestClient(calling_func_name())
client.open(url=ADMIN_URL)
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_defaultDeleteAdminAction():
'''Admin Actions test. Test the default delete action.'''
client = WindmillTestClient(calling_func_name())
client.open(url=ADMIN_URL)
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_dateTimeModelsandWidgets():
client = WindmillTestClient(calling_func_name())
client.open(url=ADMIN_URL)
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_inlineEditandCreate():
client = WindmillTestClient(calling_func_name())
client.open(url=ADMIN_URL)
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_adminActionEmptyModels():
client = WindmillTestClient(calling_func_name())
client.open(url=ADMIN_URL)
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')
def test_parentChildRelationship():
client = WindmillTestClient(calling_func_name())
client.open(url=ADMIN_URL)
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.open(url=ADMIN_URL)
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(calling_func_name())
client.open(url=ADMIN_URL)
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')
#print client.commands.getPageText()
client.asserts.assertNode(link=u'adduser')
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'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' Home ')
client.waits.forPageLoad(timeout=u'20000')
def test_contribFlatSitesRedirect():
client = WindmillTestClient(calling_func_name())
client.open(url=ADMIN_URL)
client.waits.forPageLoad(timeout=u'20000')
#print client.commands.getPageText()
client.click(xpath=u"//div[@id='content-main']/div[table/caption/a/text()='Flatpages']/table/tbody/tr[1]/td/a")
client.waits.forPageLoad(timeout=u'20000')
#print client.commands.getPageText()
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.select(id='id_sites', val=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[table/caption/a/text()='Sites']/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:8000', 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'\nThis is some unique test content.\n')
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[table/caption/a/text()='Redirects']/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'\nThis is some unique test content.\n')
client.open(url=u'http://localhost:8000/test_admin/admin/')
client.waits.forPageLoad(timeout=u'8000')
client.click(link=u'Log out')
client.waits.forPageLoad(timeout=u'20000')
def test_ensureLogout():
client = WindmillTestClient(calling_func_name())
client.open(url=ADMIN_URL)
client.waits.forPageLoad(timeout=u'20000')
client.open(url="%s/accounts/logout"% global_settings.TEST_URL)
client.waits.forPageLoad(timeout=u'20000')
client.asserts.assertText(xpath=u"//div[@id='content']/h1", validator=u'Logged out')
client.asserts.assertText(xpath=u"//div[@id='content']/p", validator=u'Thanks for spending some quality time with the Web site today.')
client.asserts.assertNode(link=u'Log in again')
from primary import *

View File

@ -0,0 +1,493 @@
from windmill.authoring import WindmillTestClient
from django.test.utils import calling_func_name
from windmill.conf import global_settings
ADMIN_URL = "%s/test_admin/admin" % global_settings.TEST_URL
def test_loginAndSetup():
'''Mostly just a proof of concept to test working order of tests.'''
client = WindmillTestClient(calling_func_name())
# print dir(client)
# print dir(client.open)
# print dir(client.commands)
# print client.commands()
client.open(url=ADMIN_URL)
client.waits.forPageLoad(timeout=u'20000')
client.open(url=ADMIN_URL)
client.waits.forPageLoad(timeout=u'20000')
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_changeListNamingLinkingHistory():
'''Creating a Model with strings for pk, and checking history.'''
client = WindmillTestClient(calling_func_name())
client.open(url=ADMIN_URL)
client.waits.forPageLoad(timeout=u'20000')
# client.open(url=ADMIN_URL)
# 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_filtersSearchOnChangeList():
'''Testing Updates and Filters/Search on Person Models'''
client = WindmillTestClient(calling_func_name())
client.open(url=ADMIN_URL)
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_defaultDeleteAdminAction():
'''Admin Actions test. Test the default delete action.'''
client = WindmillTestClient(calling_func_name())
client.open(url=ADMIN_URL)
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_dateTimeModelsandWidgets():
client = WindmillTestClient(calling_func_name())
client.open(url=ADMIN_URL)
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_inlineEditandCreate():
client = WindmillTestClient(calling_func_name())
client.open(url=ADMIN_URL)
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_adminActionEmptyModels():
client = WindmillTestClient(calling_func_name())
client.open(url=ADMIN_URL)
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')
def test_parentChildRelationship():
client = WindmillTestClient(calling_func_name())
client.open(url=ADMIN_URL)
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.open(url=ADMIN_URL)
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(calling_func_name())
client.open(url=ADMIN_URL)
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')
#print client.commands.getPageText()
client.asserts.assertNode(link=u'adduser')
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'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' Home ')
client.waits.forPageLoad(timeout=u'20000')
def test_contribFlatSitesRedirect():
client = WindmillTestClient(calling_func_name())
client.open(url=ADMIN_URL)
client.waits.forPageLoad(timeout=u'20000')
#print client.commands.getPageText()
client.click(xpath=u"//div[@id='content-main']/div[table/caption/a/text()='Flatpages']/table/tbody/tr[1]/td/a")
client.waits.forPageLoad(timeout=u'20000')
#print client.commands.getPageText()
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.select(id='id_sites', val=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[table/caption/a/text()='Sites']/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:8000', 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'\nThis is some unique test content.\n')
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[table/caption/a/text()='Redirects']/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'\nThis is some unique test content.\n')
client.open(url=u'http://localhost:8000/test_admin/admin/')
client.waits.forPageLoad(timeout=u'8000')
client.click(link=u'Log out')
client.waits.forPageLoad(timeout=u'20000')
def test_ensureLogout():
client = WindmillTestClient(calling_func_name())
client.open(url=ADMIN_URL)
client.waits.forPageLoad(timeout=u'20000')
client.open(url="%s/accounts/logout"% global_settings.TEST_URL)
client.waits.forPageLoad(timeout=u'20000')
client.asserts.assertText(xpath=u"//div[@id='content']/h1", validator=u'Logged out')
client.asserts.assertText(xpath=u"//div[@id='content']/p", validator=u'Thanks for spending some quality time with the Web site today.')
client.asserts.assertNode(link=u'Log in again')

View File

@ -178,8 +178,12 @@ def django_tests(verbosity, interactive, test_labels):
if not hasattr(settings, 'TEST_RUNNER'):
settings.TEST_RUNNER = 'django.test.simple.run_tests'
#establish coverage settings for the regression suite
settings.COVERAGE_MODULE_EXCLUDES = ['modeltests*', 'regressiontests*', 'from .* import .*', 'import .*',]
settings.COVERAGE_CODE_EXCLUDES = ['def __unicode__\(self\):', 'def get_absolute_url\(self\):']
settings.COVERAGE_MODULE_EXCLUDES = ['modeltests*', 'regressiontests*']
settings.COVERAGE_CODE_EXCLUDES = ['def __unicode__\(self\):',
'def get_absolute_url\(self\):',
'from .* import .*',
'import .*',
'from *']
# depending on how this is run, we might need to tell the coverage libraries to consider django.*
settings.COVERAGE_ADDITIONAL_MODULES = ['django']