[KSS-checkins] r53364 - in kukit/kss.demo/branch/1.4-kss-test/kss/demo: . tests
reebalazs at codespeak.net
reebalazs at codespeak.net
Fri Apr 4 23:29:03 CEST 2008
Author: reebalazs
Date: Fri Apr 4 23:29:01 2008
New Revision: 53364
Added:
kukit/kss.demo/branch/1.4-kss-test/kss/demo/selenium_suites.txt (contents, props changed)
Modified:
kukit/kss.demo/branch/1.4-kss-test/kss/demo/tests/test_doc.py
Log:
Add more tests
Added: kukit/kss.demo/branch/1.4-kss-test/kss/demo/selenium_suites.txt
==============================================================================
--- (empty file)
+++ kukit/kss.demo/branch/1.4-kss-test/kss/demo/selenium_suites.txt Fri Apr 4 23:29:01 2008
@@ -0,0 +1,145 @@
+
+====================
+Selenium test suites
+====================
+
+Selenium test suites can be set up from plugin resource definitions.
+
+ >>> from kss.demo import (
+ ... KSSSeleniumTestSuite,
+ ... KSSSeleniumTestCase,
+ ... )
+
+ >>> class Plugin(object):
+ ...
+ ... selenium_tests = (
+ ... KSSSeleniumTestSuite(
+ ... tests = KSSSeleniumTestCase('1'),
+ ... ),
+ ... )
+ >>> suite1 = Plugin.selenium_tests[0]
+
+A suite is like a testcase collection, so it provides its allowed
+resource filenames. These are used to secure the resource handling
+(to select which files can be served from the filesystem).
+
+ >>> tuple(suite1.get_testcase_paths())
+ ('1', '...setDevMode.html', '...setProdMode.html')
+
+(Normally we would see an absolute path in place of '1', but the module
+finder does not work from within doctests.)
+
+And the list of test urls as well. (We use in place of the view which
+is not important in this case.)
+
+ >>> tuple(suite1.get_relative_urls(None))
+ ('@@resource?path=...setDevMode.html', '@@resource?path=1', '@@resource?path=...setProdMode.html', '@@resource?path=1')
+
+
+Dual and single mode
+--------------------
+
+The `suite1` suite also executes the tests twice, both in development and production mode.
+If we want single mode for a given suite, we can set it with setting the `dual_mode`
+parameter of the suite to False.
+
+ >>> class Plugin2(object):
+ ...
+ ... selenium_tests = (
+ ... KSSSeleniumTestSuite(
+ ... tests = KSSSeleniumTestCase('2'),
+ ... dual_mode = False,
+ ... ),
+ ... )
+ >>> suite2 = Plugin2.selenium_tests[0]
+
+ >>> tuple(suite2.get_relative_urls(None))
+ ('@@resource?path=2',)
+
+
+Using test layers
+-----------------
+
+We can define a layer to the suite, with its own setup and teardown.
+
+ >>> from kss.demo import KSSSeleniumTestLayerBase
+
+ >>> class aLayer(KSSSeleniumTestLayerBase):
+ ... setup = KSSSeleniumTestCase('sa')
+ ... teardown = KSSSeleniumTestCase('ta')
+
+Now we add a suite with this layer.
+
+ >>> class Plugin3(object):
+ ...
+ ... selenium_tests = (
+ ... KSSSeleniumTestSuite(
+ ... tests = KSSSeleniumTestCase('3'),
+ ... layer = aLayer,
+ ... ),
+ ... )
+ >>> suite3 = Plugin3.selenium_tests[0]
+
+Check the results:
+
+ >>> tuple(suite3.get_testcase_paths())
+ ('3', 'sa', 'ta', '...setDevMode.html', '...setProdMode.html')
+
+ >>> tuple(suite3.get_relative_urls(None))
+ ('@@resource?path=sa', '@@resource?path=...setDevMode.html', '@@resource?path=3', '@@resource?path=...setProdMode.html', '@@resource?path=3', '@@resource?path=ta')
+
+
+Inheritence of layers
+---------------------
+
+Layers can inherit from each other.
+
+ >>> class bLayer(aLayer):
+ ... setup = KSSSeleniumTestCase('sb')
+ ... teardown = KSSSeleniumTestCase('tb')
+
+ >>> class Plugin4(object):
+ ...
+ ... selenium_tests = (
+ ... KSSSeleniumTestSuite(
+ ... tests = KSSSeleniumTestCase('4'),
+ ... layer = bLayer,
+ ... ),
+ ... )
+ >>> suite4 = Plugin4.selenium_tests[0]
+
+ >>> tuple(suite4.get_testcase_paths())
+ ('4', 'sb', 'tb', '...setDevMode.html', '...setProdMode.html')
+
+ >>> tuple(suite4.get_relative_urls(None))
+ ('@@resource?path=sa', '@@resource?path=sb', '@@resource?path=...setDevMode.html', '@@resource?path=4', '@@resource?path=...setProdMode.html', '@@resource?path=4', '@@resource?path=tb', '@@resource?path=ta')
+
+
+Generating tests for a set of resources
+---------------------------------------
+
+Normally, the tests are not collected from suites individually, but a tree is built from a set
+of suites providing an optimal setup and teardown sequence. This is done by the demo utility itself.
+The list of suites is originating from various different plugins.
+
+ >>> class Plugin5(object):
+ ...
+ ... selenium_tests = (
+ ... KSSSeleniumTestSuite(
+ ... tests = KSSSeleniumTestCase('5a'),
+ ... layer = aLayer,
+ ... ),
+ ... KSSSeleniumTestSuite(
+ ... tests = KSSSeleniumTestCase('5b'),
+ ... layer = bLayer,
+ ... ),
+ ... )
+
+ >>> from kss.demo.selenium_layer import LayerTree
+ >>> tree = LayerTree(Plugin5.selenium_tests + (suite2, ))
+ >>> tuple(tree.get_relative_urls(None))
+ ('@@resource?path=2', '@@resource?path=sa', '@@resource?path=...setDevMode.html', '@@resource?path=5a', '@@resource?path=...setProdMode.html', '@@resource?path=5a', '@@resource?path=sb', '@@resource?path=...setDevMode.html', '@@resource?path=5b', '@@resource?path=...setProdMode.html', '@@resource?path=5b', '@@resource?path=tb', '@@resource?path=ta')
+
+More testing of the layers can be found in the selenium_layers.txt file.
+
+
Modified: kukit/kss.demo/branch/1.4-kss-test/kss/demo/tests/test_doc.py
==============================================================================
--- kukit/kss.demo/branch/1.4-kss-test/kss/demo/tests/test_doc.py (original)
+++ kukit/kss.demo/branch/1.4-kss-test/kss/demo/tests/test_doc.py Fri Apr 4 23:29:01 2008
@@ -25,4 +25,8 @@
package = 'kss.demo',
optionflags = doctest.ELLIPSIS,
),
+ DocFileSuite('selenium_suites.txt',
+ package = 'kss.demo',
+ optionflags = doctest.ELLIPSIS,
+ ),
))
More information about the Kukit-checkins
mailing list