Skip to content

Commit

Permalink
[#1576][templates,tests]: Tidied up test ini files to suit postgres e…
Browse files Browse the repository at this point in the history
…xtension testing and provided docs. Fixed broken util test. Corrected Statistics footer link that was appearing when no stats enabled.
  • Loading branch information
David Read committed Jan 3, 2012
1 parent 8457a34 commit eb245a5
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 9 deletions.
2 changes: 1 addition & 1 deletion ckan/templates/layout_base.html
Expand Up @@ -156,7 +156,7 @@ <h3 class="widget-title">Sections</h3>
Tags
</a>
</li>
<li>
<li py:if="'stats' in config.get('ckan.plugins','').split(' ')">
<a href="${url('stats')}">
Statistics
</a>
Expand Down
4 changes: 1 addition & 3 deletions ckan/tests/functional/api/test_util.py
Expand Up @@ -124,7 +124,5 @@ def test_status(self):
assert_equal(res['locale_default'], 'en')

assert_equal(type(res['extensions']), list)
expected_extensions = set()
if not model.engine_is_sqlite():
expected_extensions.add('synchronous_search')
expected_extensions = set(('stats',))
assert_equal(set(res['extensions']), expected_extensions)
4 changes: 3 additions & 1 deletion ckan/tests/functional/test_pagination.py
Expand Up @@ -34,11 +34,13 @@ def teardown_class(self):
def test_search(self):
res = self.app.get(url_for(controller='package', action='search', q='groups:group_00'))
assert 'href="/dataset?q=groups%3Agroup_00&amp;page=2"' in res
assert 'href="/dataset/package_19"' in res
assert 'href="/dataset/package_00"' in res, res
assert 'href="/dataset/package_19"' in res, res

res = self.app.get(url_for(controller='package', action='search', q='groups:group_00', page=2))
assert 'href="/dataset?q=groups%3Agroup_00&amp;page=1"' in res
assert 'href="/dataset/package_20"' in res
assert 'href="/dataset/package_39"' in res

def test_group_index(self):
res = self.app.get(url_for(controller='group', action='index'))
Expand Down
10 changes: 10 additions & 0 deletions doc/common-error-messages.rst
Expand Up @@ -101,3 +101,13 @@ This suggests that the config file specified with the paster ``--config`` parame
===========================================

This occurs when trying to ``import migrate.exceptions`` and is due to the version of sqlalchemy-migrate being used is too old - check the requires files for the version needed.

``ckan.plugins.core.PluginNotFoundException: stats``
====================================================

After the CKAN 1.5.1 release, the Stats extension was merged into the core CKAN code, and the ckanext namespace needs registering before the tests will run::

cd pyenv/src/ckan
python setup.py develop

Otherwise, this problem may be to enabling an extension which is not installed. See: :doc:`extensions`_.
7 changes: 7 additions & 0 deletions doc/test.rst
Expand Up @@ -99,6 +99,13 @@ By default, tests are run using the model defined in ``ckan/model``, but by usin
A common error when wanting to run tests against a particular database is to change ``sqlalchemy.url`` in ``test.ini`` or ``test-core.ini``. The problem is that these are versioned files and people have checked in these by mistake, creating problems for other developers and the CKAN buildbot. This is easily avoided by only changing ``sqlalchemy.url`` in your local ``development.ini`` and testing ``--with-pylons=test-core.ini``.
Testing Core Extensions
-----------------------

Some extensions are in the CKAN core codebase and have their own suite of tests. For example::

nosetests --ckan ckanext/stats/tests

Common error messages
---------------------

Expand Down
4 changes: 3 additions & 1 deletion test-core.ini
Expand Up @@ -45,7 +45,7 @@ search_backend = sql
# Change API key HTTP header to something non-standard.
apikey_header_name = X-Non-Standard-CKAN-API-Key

# ckan.plugins = amqp_notifier
ckan.plugins = stats

# use <strong> so we can check that html is *not* escaped
ckan.template_head_end = <link rel="stylesheet" href="TEST_TEMPLATE_HEAD_END.css" type="text/css">
Expand All @@ -59,6 +59,8 @@ ckan.mail_from = info@test.ckan.net

ckan.locale_default = en

ckanext.stats.cache_enabled = 0

# Logging configuration
[loggers]
keys = root, ckan, sqlalchemy
Expand Down
3 changes: 0 additions & 3 deletions test.ini
Expand Up @@ -22,12 +22,9 @@ use = config:test-core.ini
# run fast.
faster_db_test_hacks = True
sqlalchemy.url = sqlite:///
ckan.plugins = stats
# NB: other test configuration should go in test-core.ini, which is
# what the postgres tests use.

ckanext.stats.cache_enabled = 0

# Logging configuration
[loggers]
keys = root, ckan, sqlalchemy
Expand Down

0 comments on commit eb245a5

Please sign in to comment.