[ckan-dev] Create a temporary database for CKAN plugin nose tests

Sean Hammond sean.hammond at okfn.org
Mon Feb 25 09:38:52 UTC 2013


> I believe you can specify the database to use in the .ini file given to
> nosetests but the test do not drop/create the database.  They will
> drop/create tables in the database though.  dropping/creating databases
> require elevated permissions.

Right, if you add an sqlalchemy,url setting to test-core.ini, like:

  sqlalchemy.url = postgresql://ckanuser:pass@localhost/ckantest

that'll change the database (and user and password) that the ckan tests
use. 'ckanuser', 'pass' and 'ckantest' can be any postgresql user,
password and database. Just set it to a different database from the one
your development or production ini file uses, and then it won't
overwrite your data when the tests run. (But yes, I think you'll have to
create the database and user once first, see CKAN's source-install
instructions for the commands to do this.)

@ckan-devs, I wonder if maybe we should make test-core.ini use a
different database from the development/production ini file template by
default? I think it does surprise people when running the tests wipes
all their data (and it's also annoying).




More information about the ckan-dev mailing list