In order to run the tests you must first have Selenium RC started. To learn how to start it go back to the previous section.
from funittest import interpreter dry_run = interpreter.is_dry_run() if dry_run: print "Could not connect to Selenium RC" else: print "Connected to Selenium RC"
If you haven't already got your Plone instance running on port 8080 start that now. This test expects a Plone 3.0.X instance at /Plone.
import urllib2 try: urllib2.urlopen('http://localhost:8080/Plone') print "Your Plone instance is running" except: print "ERROR - Make sure your plone instance is configured before attempting to run these tests"
It can turn out useful to keep an eye on the installed product list, and to report a problem in case a product is missing or has been installed unexpectedly.
The list of expected products is stored in the product dataprovider, and should be empty for a standard Plone site:
from funittest import dataprovider print dataprovider.cmfplone.product.current
Let's change the current setting and expect NuPlone to be installed:
from funittest import dataprovider dataprovider.cmfplone.product.current=["NuPlone",] print dataprovider.cmfplone.product.current
The test will log in as an admin and look at the list of installed products. If you have added NuPlone to the list of current products, an error should appear. Otherwise, the test will be ok if nothing is installed.
from funittest import tests installedproductstest = tests.cmfplone.installedproducts from funittest import testrunner runner = testrunner.TestRunner([installedproductstest,]) runner.run()
The following test will tell you whether all content types that an administrator is expected to be able to add to the Plone site root appear in the add drop down list. This test can be really useful to make sure that only the expected content types are addable.
The list of expected addable content types is stored in the content dataprovider:
from funittest import dataprovider print dataprovider.cmfplone.content.keys()
The test will just log in as an admin and look at the list of addable types in the drop down and compare it to the standard Plone content types that are expected to be addable by default. If you have installed a product that comes with an additional content type, the test will fail. Try restricting the addable types, to see how the test will complain about missing content types.
from funittest import tests addablecontenttest = tests.cmfplone.addablecontent from funittest import testrunner runner = testrunner.TestRunner([addablecontenttest,]) runner.run()
The next test goes just one step further and actually tries adding the content types without editing or saving them. This test can be really useful to make sure that the content type is not broken and adding it basically works.
Again, the test will just log in as an admin and add all content types one after the other. If you have installed additional products with new content types, they will be included in the test automatically.
from funittest import tests addcontenttest = tests.cmfplone.addcontent from funittest import testrunner runner = testrunner.TestRunner([addcontenttest,]) runner.run()
Now that you know about a few tests available in Funittest, you should learn about Scenarios, which are the building blocks of our custom tests. Use case scenarios in Funittest.