Author: reebalazs
Date: Sat Mar 29 11:09:47 2008
New Revision: 53079
Modified:
kukit/kss.demo/branch/1.4-kss-test/kss/demo/browser/kss-selenium-create-sandbox-test.pt
kukit/kss.demo/branch/1.4-kss-test/kss/demo/browser/kss_demo_suite.pt
kukit/kss.demo/branch/1.4-kss-test/kss/demo/browser/registry.py
kukit/kss.demo/branch/1.4-kss-test/kss/demo/interfaces.py
kukit/kss.demo/branch/1.4-kss-test/kss/demo/registry.py
kukit/kss.demo/branch/1.4-kss-test/kss/demo/resource.py
Log:
Make the selection based on application work
- we needed to add a view parameter to get_relative_urls
- enhanced the url to title generation
Modified:
kukit/kss.demo/branch/1.4-kss-test/kss/demo/browser/kss-selenium-create-sandbox-test.pt
==============================================================================
---
kukit/kss.demo/branch/1.4-kss-test/kss/demo/browser/kss-selenium-create-sandbox-test.pt
(original)
+++
kukit/kss.demo/branch/1.4-kss-test/kss/demo/browser/kss-selenium-create-sandbox-test.pt
Sat Mar 29 11:09:47 2008
@@ -18,7 +18,7 @@
<td tal:define="method_name request/method_name | nothing;
admin_username request/admin_username | nothing;
admin_password request/admin_password | nothing"
- tal:content="string:
${context/@@absolute_url}/demo/@@kss-selenium-create-sandbox-ui.html?method_name=${method_name}&admin_username=${admin_username}&admin_password=${admin_password}">
+ tal:content="string:
${context/@@absolute_url}/@@kss-selenium-create-sandbox-ui.html?method_name=${method_name}&admin_username=${admin_username}&admin_password=${admin_password}">
</td>
<td></td>
</tr>
Modified: kukit/kss.demo/branch/1.4-kss-test/kss/demo/browser/kss_demo_suite.pt
==============================================================================
--- kukit/kss.demo/branch/1.4-kss-test/kss/demo/browser/kss_demo_suite.pt
(original)
+++ kukit/kss.demo/branch/1.4-kss-test/kss/demo/browser/kss_demo_suite.pt
Sat Mar 29 11:09:47 2008
@@ -5,7 +5,8 @@
cellspacing="1"
border="1"
class="selenium">
- <tbody tal:define="selenium_tests
context/@@kss_demo_registry/getSeleniumTests">
+ <tbody tal:define="selenium_tests nocall:
context/@@kss_demo_registry/getSeleniumTests;
+ application python:request.get('application', '')">
<tr><td><b>Test Suite</b></td></tr>
<tr>
<td>
@@ -14,7 +15,7 @@
</h4>
</td>
</tr>
- <tal:groups repeat="selenium_test selenium_tests">
+ <tal:groups repeat="selenium_test python: selenium_tests(application)">
<tr>
<td><a href="test.html"
tal:content="selenium_test/title"
@@ -30,7 +31,7 @@
</h4>
</td>
</tr>
- <tal:groups repeat="selenium_test selenium_tests">
+ <tal:groups repeat="selenium_test python: selenium_tests(application)">
<tr>
<td><a href="test.html"
tal:content="selenium_test/title"
Modified: kukit/kss.demo/branch/1.4-kss-test/kss/demo/browser/registry.py
==============================================================================
--- kukit/kss.demo/branch/1.4-kss-test/kss/demo/browser/registry.py
(original)
+++ kukit/kss.demo/branch/1.4-kss-test/kss/demo/browser/registry.py Sat Mar
29 11:09:47 2008
@@ -6,6 +6,7 @@
from zope.interface import implements
from kss.demo.selenium_utils.builder import cookSeleniumTests
import os.path
+import re
try:
from Products.Five import BrowserView
BrowserView # make pyflakes happy
@@ -64,12 +65,14 @@
# handling the selenium tests
# --
- def getSeleniumTests(self):
+ def getSeleniumTests(self, application=''):
"""Get selenium tests annotated with title and href."""
registry = getUtility(IKSSDemoRegistry)
results = []
for suite in registry.test_suites:
- relative_urls = suite.get_relative_urls()
+ if not suite.application.lower() == application.strip().lower():
+ continue
+ relative_urls = suite.get_relative_urls(self)
for relative_url in relative_urls:
results.append(dict(
href = relative_url,
@@ -83,14 +86,21 @@
# we use the url's end after the last /, @ or *
split_here = max(url.rfind('/'), url.rfind('*'), url.rfind('+'))
if split_here != -1:
- filename = url[split_here:]
- else:
- filename = url
+ url = url[split_here + 1:]
+ # get rid of parameters
+ split_end = url.find('?')
+ if split_end != -1:
+ url = url[:split_end - 1]
+ # finally get rid of the @
+ split_here = url.rfind('@')
+ if split_here != -1:
+ url = url[split_here + 1:]
+ filename = url
if filename.lower().endswith('.html'):
filename = filename[:-5]
elif filename.lower().endswith('.htm'):
filename = filename[:-4]
- words = os.path.basename(filename).split('_')
+ words = re.split('[_-]', os.path.basename(filename))
# if the first word is a number: it is ignored in the title
# This can be used to somelimited ordering, since filenames
# are listed in alphabetical order, ie. 00_xxx.html will come first.
Modified: kukit/kss.demo/branch/1.4-kss-test/kss/demo/interfaces.py
==============================================================================
--- kukit/kss.demo/branch/1.4-kss-test/kss/demo/interfaces.py (original)
+++ kukit/kss.demo/branch/1.4-kss-test/kss/demo/interfaces.py Sat Mar 29
11:09:47 2008
@@ -49,10 +49,14 @@
class IKSSSeleniumTestCaseCollection(Interface):
"""Abstract interface representing a set of testcases"""
- def get_relative_urls():
+ def get_relative_urls(view):
"""Return the list of relative urls in this collection
Each of theses urls will serve an .html format selenium
test case.
+
+ This method takes the view that renders it as parameter.
+ This is needed in some cases (like for the site creation suite url)
+ to access the admin_username, admin_password parameters.
"""
def get_testcase_paths():
@@ -75,16 +79,14 @@
component = TextLine(
title = u'Component name',
description = u'Import identifier of the component that defines this
suite.',
- required = False,
- default = u'',
+ required = True,
)
application = TextLine(
title = u'Application name',
description = u'Freeform identifier of the application that this suite
tests.'
u'It is suggested but not obligatory to use dotted names
for this.',
- required = False,
- default = u'',
+ required= True,
)
layer = Object(IKSSSeleniumTestLayer,
Modified: kukit/kss.demo/branch/1.4-kss-test/kss/demo/registry.py
==============================================================================
--- kukit/kss.demo/branch/1.4-kss-test/kss/demo/registry.py (original)
+++ kukit/kss.demo/branch/1.4-kss-test/kss/demo/registry.py Sat Mar 29
11:09:47 2008
@@ -48,6 +48,8 @@
# registry for selenium tests
self.test_suites = []
self.all_registered_paths = []
+ self.applications = []
+ #
site.registerHandler(self.registerSeleniumTestSuitesFromPlugin)
site.registerHandler(self.unregisterSeleniumTestSuitesFromPlugin)
# ... the rest of setup will be done from registerEarlierDemos
@@ -63,7 +65,7 @@
return
site = getSiteManager()
for name, plugin in site.getUtilitiesFor(IKSSDemoResource):
- for demo in plugin.demos:
+ for demo in getattr(plugin, 'demos', ()):
self.registerDemo(demo)
test_suites =
self._convertLegacySeleniumTestSuitesFromPlugin(plugin)
for test_suite in test_suites:
@@ -73,14 +75,14 @@
def registerDemosFromPlugin(self, plugin, registration=None, event=None,
new_event=None):
"""Add a demo collection to the registry.
"""
- for demo in plugin.demos:
+ for demo in getattr(plugin, 'demos', ()):
self.registerDemo(demo)
@adapter(IKSSDemoResource, IUtilityRegistration, IUnregistered,
IKSSDemoRegistrationEvent)
def unregisterDemosFromPlugin(self, plugin, registration=None, event=None,
new_event=None):
"""Remove a demo collection from the registry.
"""
- for demo in plugin.demos:
+ for demo in getattr(plugin, 'demos', ()):
self.unregisterDemo(demo)
def registerDemo(self, demo):
@@ -137,7 +139,7 @@
# directories. Now we always have test suites. So when we encounter
# a directory, we wrap it as a test suite.
test_suites = []
- for test_suite in plugin.selenium_tests:
+ for test_suite in getattr(plugin, 'selenium_tests', ()):
if not IKSSSeleniumTestSuite.providedBy(test_suite):
# legacy way, need to wrap it to be a suite
test_suite = KSSSeleniumTestSuite(tests=test_suite)
@@ -166,6 +168,8 @@
self.test_suites.append(test_suite)
self.all_registered_paths.extend(test_suite.tests.get_testcase_paths())
# XXX TODO need different other registries for lookup of categories.
+ if test_suite.application not in self.applications:
+ self.applications.append(test_suite.application)
def unregisterSeleniumTestSuite(self, test_suite):
"""Unregister the given selenium suite."""
Modified: kukit/kss.demo/branch/1.4-kss-test/kss/demo/resource.py
==============================================================================
--- kukit/kss.demo/branch/1.4-kss-test/kss/demo/resource.py (original)
+++ kukit/kss.demo/branch/1.4-kss-test/kss/demo/resource.py Sat Mar 29
11:09:47 2008
@@ -70,7 +70,7 @@
test_filename = self.find_absolute_path(self.test_filename)
return [test_filename]
- def get_relative_urls(self):
+ def get_relative_urls(self, view):
return self.make_relative_urls_from_paths(self.get_testcase_paths())
class KSSSeleniumTestDirectory(KSSSeleniumTestCaseCollectionBase):
@@ -96,7 +96,7 @@
test_filenames = (filename[1] for filename in test_filenames)
return test_filenames
- def get_relative_urls(self):
+ def get_relative_urls(self, view):
return self.make_relative_urls_from_paths(self.get_testcase_paths())
class KSSSeleniumTestCaseList(KSSSeleniumTestCaseCollectionBase):
@@ -111,8 +111,8 @@
def get_testcase_paths(self):
return itertools.chain(*[case.get_testcase_paths() for case in
self.cases])
- def get_relative_urls(self):
- return itertools.chain(*[case.get_relative_urls() for case in
self.cases])
+ def get_relative_urls(self, view):
+ return itertools.chain(*[case.get_relative_urls(view) for case in
self.cases])
class KSSSeleniumEmptyTestCase(KSSSeleniumTestCaseCollectionBase):
"""An empty test case."""
@@ -121,7 +121,7 @@
def get_testcase_paths(self):
return ()
- def get_relative_urls(self):
+ def get_relative_urls(self, view):
return ()
@@ -148,11 +148,11 @@
def get_testcase_paths(self):
return ()
- def get_relative_urls(self):
- relative_url =
"@@kss-selenium-create-sandbox-suite.html?method_name=%s&admin_username=%s&admin_password=%s"
% (
+ def get_relative_urls(self, view):
+ relative_url =
"@@kss-selenium-create-sandbox-test.html?method_name=%s&admin_username=%s&admin_password=%s"
% (
self.method_name,
- self.request.get('admin_username', ''),
- self.request.get('admin_password', ''))
+ view.request.get('admin_username', ''),
+ view.request.get('admin_password', ''))
return (relative_url, )
# --
@@ -164,12 +164,13 @@
setup = KSSSeleniumEmptyTestCase()
teardown = KSSSeleniumEmptyTestCase()
-# XXX TODO Currently the test suite handles the setup and teardown
+# XXX TODO Currently the tuest suite handles the setup and teardown
# of the layer. The suites with the same layer should have a common
# setup. Very easy to implement.
class KSSSeleniumTestSuite(object):
- """Represents a single selenium test case,
- specified by its filename.
+ """Represents a selenium suite,
+ that makes part of an applicaion and a component,
+ as well as an optional (test) layer.
"""
implements(IKSSSeleniumTestSuite)
@@ -199,9 +200,9 @@
self.layer.teardown.get_testcase_paths()
)
- def get_relative_urls(self):
+ def get_relative_urls(self, view):
return itertools.chain(
- self.layer.setup.get_relative_urls(),
- self.tests.get_relative_urls(),
- self.layer.teardown.get_relative_urls()
+ self.layer.setup.get_relative_urls(view),
+ self.tests.get_relative_urls(view),
+ self.layer.teardown.get_relative_urls(view)
)
_______________________________________________
Kukit-checkins mailing list
[email protected]
http://codespeak.net/mailman/listinfo/kukit-checkins