Author: kkubasik
Date: 2009-06-16 20:27:20 -0500 (Tue, 16 Jun 2009)
New Revision: 11015
Added:
django/branches/soc2009/test-improvements/django/core/management/commands/test_windmill.py
django/branches/soc2009/test-improvements/tests/windmill_dev/
django/branches/soc2009/test-improvements/tests/windmill_dev/__init__.py
django/branches/soc2009/test-improvements/tests/windmill_dev/manage.py
django/branches/soc2009/test-improvements/tests/windmill_dev/settings.py
django/branches/soc2009/test-improvements/tests/windmill_dev/testapp/
django/branches/soc2009/test-improvements/tests/windmill_dev/testapp/__init__.py
django/branches/soc2009/test-improvements/tests/windmill_dev/testapp/models.py
django/branches/soc2009/test-improvements/tests/windmill_dev/testapp/tests.py
django/branches/soc2009/test-improvements/tests/windmill_dev/testapp/views.py
django/branches/soc2009/test-improvements/tests/windmill_dev/testapp/windmilltests/
django/branches/soc2009/test-improvements/tests/windmill_dev/testapp/windmilltests/__init__.py
django/branches/soc2009/test-improvements/tests/windmill_dev/urls.py
Modified:
django/branches/soc2009/test-improvements/tests/runtests.py
Log:
[gsoc2009-testing] Creating a placeholder project for developing the windmill
tests against. Also integrated the test_windmill command for the time being,
although that needs discussion.
Added:
django/branches/soc2009/test-improvements/django/core/management/commands/test_windmill.py
===================================================================
---
django/branches/soc2009/test-improvements/django/core/management/commands/test_windmill.py
(rev 0)
+++
django/branches/soc2009/test-improvements/django/core/management/commands/test_windmill.py
2009-06-17 01:27:20 UTC (rev 11015)
@@ -0,0 +1,102 @@
+from django.core.management.base import BaseCommand
+from windmill.authoring import djangotest
+import sys, os
+from time import sleep
+import types
+import logging
+
+class ServerContainer(object):
+ start_test_server = djangotest.start_test_server
+ stop_test_server = djangotest.stop_test_server
+
+def attempt_import(name, suffix):
+ try:
+ mod = __import__(name+'.'+suffix)
+ except ImportError:
+ mod = None
+ if mod is not None:
+ s = name.split('.')
+ mod = __import__(s.pop(0))
+ for x in s+[suffix]:
+ mod = getattr(mod, x)
+ return mod
+
+class Command(BaseCommand):
+
+ help = "Run windmill tests. Specify a browser, if one is not passed
Firefox will be used"
+
+ args = '<label label ...>'
+ label = 'label'
+
+ def handle(self, *labels, **options):
+
+ 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')
+
+ 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 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 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)
Modified: django/branches/soc2009/test-improvements/tests/runtests.py
===================================================================
--- django/branches/soc2009/test-improvements/tests/runtests.py 2009-06-16
16:42:46 UTC (rev 11014)
+++ django/branches/soc2009/test-improvements/tests/runtests.py 2009-06-17
01:27:20 UTC (rev 11015)
@@ -166,6 +166,9 @@
failures = tr.run_tests(test_labels, verbosity=verbosity,
interactive=interactive, extra_tests=extra_tests)
if failures:
sys.exit(failures)
+ from django.core.management.commands.test_windmill import Command as
testwm_cmd
+ windmill_runner = testwm_cmd()
+ windmill_runner.handle()
# Restore the old settings.
settings.INSTALLED_APPS = old_installed_apps
Added: django/branches/soc2009/test-improvements/tests/windmill_dev/__init__.py
===================================================================
Property changes on:
django/branches/soc2009/test-improvements/tests/windmill_dev/__init__.py
___________________________________________________________________
Name: svn:executable
+ *
Added: django/branches/soc2009/test-improvements/tests/windmill_dev/manage.py
===================================================================
--- django/branches/soc2009/test-improvements/tests/windmill_dev/manage.py
(rev 0)
+++ django/branches/soc2009/test-improvements/tests/windmill_dev/manage.py
2009-06-17 01:27:20 UTC (rev 11015)
@@ -0,0 +1,11 @@
+#!/usr/bin/env python
+from django.core.management import execute_manager
+try:
+ import settings # Assumed to be in the same directory.
+except ImportError:
+ import sys
+ sys.stderr.write("Error: Can't find the file 'settings.py' in the
directory containing %r. It appears you've customized things.\nYou'll have to
run django-admin.py, passing it your settings module.\n(If the file settings.py
does indeed exist, it's causing an ImportError somehow.)\n" % __file__)
+ sys.exit(1)
+
+if __name__ == "__main__":
+ execute_manager(settings)
Property changes on:
django/branches/soc2009/test-improvements/tests/windmill_dev/manage.py
___________________________________________________________________
Name: svn:executable
+ *
Added: django/branches/soc2009/test-improvements/tests/windmill_dev/settings.py
===================================================================
--- django/branches/soc2009/test-improvements/tests/windmill_dev/settings.py
(rev 0)
+++ django/branches/soc2009/test-improvements/tests/windmill_dev/settings.py
2009-06-17 01:27:20 UTC (rev 11015)
@@ -0,0 +1,83 @@
+# Django settings for windmill_dev project.
+
+DEBUG = True
+TEMPLATE_DEBUG = DEBUG
+
+ADMINS = (
+ # ('Your Name', '[email protected]'),
+)
+
+MANAGERS = ADMINS
+
+DATABASE_ENGINE = 'sqlite3' # 'postgresql_psycopg2', 'postgresql',
'mysql', 'sqlite3' or 'oracle'.
+DATABASE_NAME = 'test.db' # Or path to database file if using
sqlite3.
+DATABASE_USER = '' # Not used with sqlite3.
+DATABASE_PASSWORD = '' # Not used with sqlite3.
+DATABASE_HOST = '' # Set to empty string for localhost. Not used
with sqlite3.
+DATABASE_PORT = '' # Set to empty string for default. Not used
with sqlite3.
+
+# Local time zone for this installation. Choices can be found here:
+# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
+# although not all choices may be available on all operating systems.
+# If running in a Windows environment this must be set to the same as your
+# system time zone.
+TIME_ZONE = 'America/Chicago'
+
+# Language code for this installation. All choices can be found here:
+# http://www.i18nguy.com/unicode/language-identifiers.html
+LANGUAGE_CODE = 'en-us'
+
+SITE_ID = 1
+
+# If you set this to False, Django will make some optimizations so as not
+# to load the internationalization machinery.
+USE_I18N = True
+
+# Absolute path to the directory that holds media.
+# Example: "/home/media/media.lawrence.com/"
+MEDIA_ROOT = ''
+
+# URL that handles the media served from MEDIA_ROOT. Make sure to use a
+# trailing slash if there is a path component (optional in other cases).
+# Examples: "http://media.lawrence.com", "http://example.com/media/"
+MEDIA_URL = ''
+
+# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
+# trailing slash.
+# Examples: "http://foo.com/media/", "/media/".
+ADMIN_MEDIA_PREFIX = '/media/'
+
+# Make this unique, and don't share it with anybody.
+SECRET_KEY = '+w3^9f0n-e+08t&z@&#^47z(q...@c$a#mr^$!(ab+xdoovu%_9h'
+
+# List of callables that know how to import templates from various sources.
+TEMPLATE_LOADERS = (
+ 'django.template.loaders.filesystem.load_template_source',
+ 'django.template.loaders.app_directories.load_template_source',
+# 'django.template.loaders.eggs.load_template_source',
+)
+
+MIDDLEWARE_CLASSES = (
+ 'django.middleware.common.CommonMiddleware',
+ 'django.contrib.sessions.middleware.SessionMiddleware',
+ 'django.contrib.auth.middleware.AuthenticationMiddleware',
+)
+
+ROOT_URLCONF = 'windmill_dev.urls'
+
+TEMPLATE_DIRS = (
+ # Put strings here, like "/home/html/django_templates" or
"C:/www/django/templates".
+ # Always use forward slashes, even on Windows.
+ # Don't forget to use absolute paths, not relative paths.
+)
+
+INSTALLED_APPS = (
+ 'django.contrib.auth',
+ 'django.contrib.contenttypes',
+ 'django.contrib.sessions',
+ 'django.contrib.sites',
+ 'django.contrib.admin',
+ 'django.contrib.admindocs',
+ 'windmill',
+ 'testapp',
+)
Property changes on:
django/branches/soc2009/test-improvements/tests/windmill_dev/settings.py
___________________________________________________________________
Name: svn:executable
+ *
Added:
django/branches/soc2009/test-improvements/tests/windmill_dev/testapp/__init__.py
===================================================================
Added:
django/branches/soc2009/test-improvements/tests/windmill_dev/testapp/models.py
===================================================================
---
django/branches/soc2009/test-improvements/tests/windmill_dev/testapp/models.py
(rev 0)
+++
django/branches/soc2009/test-improvements/tests/windmill_dev/testapp/models.py
2009-06-17 01:27:20 UTC (rev 11015)
@@ -0,0 +1,3 @@
+from django.db import models
+
+# Create your models here.
Added:
django/branches/soc2009/test-improvements/tests/windmill_dev/testapp/tests.py
===================================================================
---
django/branches/soc2009/test-improvements/tests/windmill_dev/testapp/tests.py
(rev 0)
+++
django/branches/soc2009/test-improvements/tests/windmill_dev/testapp/tests.py
2009-06-17 01:27:20 UTC (rev 11015)
@@ -0,0 +1,32 @@
+"""
+This file demonstrates two different styles of tests (one doctest and one
+unittest). These will both pass when you run "manage.py test".
+
+Replace these with more appropriate tests for your application.
+"""
+
+from django.test import TestCase
+
+class SimpleTest(TestCase):
+ def test_basic_addition(self):
+ """
+ Tests that 1 + 1 always equals 2.
+ """
+ self.failUnlessEqual(1 + 1, 2)
+
+__test__ = {"doctest": """
+Another way to test that 1 + 1 is equal to 2.
+
+>>> 1 + 1 == 2
+True
+"""}
+
+import os
+from windmill.authoring import djangotest
+
+class TestProjectWindmillTest(djangotest.WindmillDjangoUnitTest):
+ test_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)),
'windmilltests')
+ #test_dir = os.path.dirname(os.path.abspath(__file__))
+ browser = 'firefox'
+
+
Added:
django/branches/soc2009/test-improvements/tests/windmill_dev/testapp/views.py
===================================================================
---
django/branches/soc2009/test-improvements/tests/windmill_dev/testapp/views.py
(rev 0)
+++
django/branches/soc2009/test-improvements/tests/windmill_dev/testapp/views.py
2009-06-17 01:27:20 UTC (rev 11015)
@@ -0,0 +1 @@
+# Create your views here.
Added:
django/branches/soc2009/test-improvements/tests/windmill_dev/testapp/windmilltests/__init__.py
===================================================================
---
django/branches/soc2009/test-improvements/tests/windmill_dev/testapp/windmilltests/__init__.py
(rev 0)
+++
django/branches/soc2009/test-improvements/tests/windmill_dev/testapp/windmilltests/__init__.py
2009-06-17 01:27:20 UTC (rev 11015)
@@ -0,0 +1,12 @@
+# Generated by the windmill services transformer
+from windmill.authoring import WindmillTestClient
+
+def test_recordingSuite0():
+ client = WindmillTestClient(__name__)
+ client.type(text="Hello", name='q')
+
client.click(xpath=u"//sp...@id='body']/center/form/table[2]/tbody/tr[8]/td")
+ client.waits.forPageLoad(timeout=u'20000')
+ client.asserts.assertNode(xpath=u"//d...@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')
\ No newline at end of file
Added: django/branches/soc2009/test-improvements/tests/windmill_dev/urls.py
===================================================================
--- django/branches/soc2009/test-improvements/tests/windmill_dev/urls.py
(rev 0)
+++ django/branches/soc2009/test-improvements/tests/windmill_dev/urls.py
2009-06-17 01:27:20 UTC (rev 11015)
@@ -0,0 +1,17 @@
+from django.conf.urls.defaults import *
+
+# Uncomment the next two lines to enable the admin:
+from django.contrib import admin
+admin.autodiscover()
+
+urlpatterns = patterns('',
+ # Example:
+ # (r'^windmill_dev/', include('windmill_dev.foo.urls')),
+
+ # Uncomment the admin/doc line below and add 'django.contrib.admindocs'
+ # to INSTALLED_APPS to enable admin documentation:
+ (r'^admin/doc/', include('django.contrib.admindocs.urls')),
+
+ # Uncomment the next line to enable the admin:
+ (r'^admin/(.*)', admin.site.root),
+)
Property changes on:
django/branches/soc2009/test-improvements/tests/windmill_dev/urls.py
___________________________________________________________________
Name: svn:executable
+ *
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---