# HG changeset patch # User Adrien Di Mascio # Date 1282914154 -7200 # Node ID 376e6c3d4002bcf9aa9ce619b290e5e9e0116b5a # Parent fc47b4e06d944467d5ce15ec5de1297fe8cac4c2 [doc] add documentation on RealDatabaseConfiguration diff -r fc47b4e06d94 -r 376e6c3d4002 devtools/testlib.py --- a/devtools/testlib.py Fri Aug 27 14:14:54 2010 +0200 +++ b/devtools/testlib.py Fri Aug 27 15:02:34 2010 +0200 @@ -25,6 +25,7 @@ import sys import re from urllib import unquote +import urlparse from math import log from contextlib import contextmanager from warnings import warn diff -r fc47b4e06d94 -r 376e6c3d4002 doc/book/en/devrepo/testing.rst --- a/doc/book/en/devrepo/testing.rst Fri Aug 27 14:14:54 2010 +0200 +++ b/doc/book/en/devrepo/testing.rst Fri Aug 27 15:02:34 2010 +0200 @@ -212,6 +212,37 @@ auto_populate cannot guess by itself; these must yield resultsets against which views may be selected. +Testing on a real-life database +------------------------------- + +The ``CubicWebTC`` class uses the `cubicweb.devtools.ApptestConfiguration` +configuration class to setup its testing environment (database driver, +user password, application home, and so on). The `cubicweb.devtools` +module also provides a `RealDatabaseConfiguration` +class that will read a regular cubicweb sources file to fetch all +this information but will also prevent the database to be initalized +and reset between tests. + +For a test class to use a specific configuration, you have to set +the `_config` class attribute on the class as in: + +.. sourcecode:: python + + from cubicweb.devtools import RealDatabaseConfiguration + from cubicweb.devtools.testlib import CubicWebTC + + class BlogRealDatabaseTC(CubicWebTC): + _config = RealDatabaseConfiguration('blog', + sourcefile='/path/to/realdb_sources') + + def test_blog_rss(self): + req = self.request() + rset = req.execute('Any B ORDERBY D DESC WHERE B is BlogEntry, ' + 'B created_by U, U login "logilab", B creation_date D') + self.view('rss', rset) + + + Testing with other cubes ------------------------