Skip to content
This repository has been archived by the owner on Apr 15, 2021. It is now read-only.

3. Setting Up CKAN: Testing

Jessica Good edited this page Aug 13, 2014 · 7 revisions

Directions below adapted from the Testing CKAN docs and Testing CKAN 2.2 docs.

Install additional dependencies

$ . ckanenv/bin/activate
(ckanenv) $ pip install -r ckanenv/src/ckan/dev-requirements.txt

Set up the test databases

(ckanenv) $ cd ckanenv/src/ckan
(ckanenv) $ sudo -u postgres createdb -O ckan_user ckan_test -E utf-8
(ckanenv) $ sudo -u postgres createdb -O ckan_user datastore_test -E utf-8
(ckanenv) $ paster datastore set-permissions postgres -c test-core.ini

Edit the Test Config File

In test-core.ini change:

sqlalchemy.url = postgresql://ckan_user:ckan_user@localhost/ckan_test
ckan.datastore.write_url = postgresql://ckan_user:password@localhost/datastore_test
ckan.datastore.read_url = postgresql://datastore_reader:password@localhost/datastore_test

ckan.storage_path = /home/ngds/ckanenv/uploaded-files-test

Run the tests

To run CKAN core (ckan) tests and ckan extensions (ckanext) tests:

$ nosetests --ckan --with-pylons=test-core.ini ckan ckanext

Running tests individually. With core ckan the following tests can be run individually: datapusher - datastore - example_iauthfunctions - example_itemplatehelpers - example_theme - multilingual - pdfpreview - reclinepreview - resourceproxy - stats - textpreview

$ nosetests --ckan --with-pylons=test-core.ini ckanext/pdfpreview

By default the tests will keep the database between test runs. If you wish to drop and reinitialize the database before the run you can use the reset-db option:

$ nosetests --ckan --reset-db --with-pylons=test-core.ini ckan
Clone this wiki locally