From eb245a5126d44c4ccdec6d597414b21dd2db2c2b Mon Sep 17 00:00:00 2001 From: David Read Date: Tue, 3 Jan 2012 18:37:12 +0000 Subject: [PATCH] [#1576][templates,tests]: Tidied up test ini files to suit postgres extension testing and provided docs. Fixed broken util test. Corrected Statistics footer link that was appearing when no stats enabled. --- ckan/templates/layout_base.html | 2 +- ckan/tests/functional/api/test_util.py | 4 +--- ckan/tests/functional/test_pagination.py | 4 +++- doc/common-error-messages.rst | 10 ++++++++++ doc/test.rst | 7 +++++++ test-core.ini | 4 +++- test.ini | 3 --- 7 files changed, 25 insertions(+), 9 deletions(-) diff --git a/ckan/templates/layout_base.html b/ckan/templates/layout_base.html index 89d662516b6..74c6f181da6 100644 --- a/ckan/templates/layout_base.html +++ b/ckan/templates/layout_base.html @@ -156,7 +156,7 @@

Sections

Tags -
  • +
  • Statistics diff --git a/ckan/tests/functional/api/test_util.py b/ckan/tests/functional/api/test_util.py index f0176b0628c..cb1ec33b95f 100644 --- a/ckan/tests/functional/api/test_util.py +++ b/ckan/tests/functional/api/test_util.py @@ -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) diff --git a/ckan/tests/functional/test_pagination.py b/ckan/tests/functional/test_pagination.py index 7f3aad43cbe..ae40935cda6 100644 --- a/ckan/tests/functional/test_pagination.py +++ b/ckan/tests/functional/test_pagination.py @@ -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&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&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')) diff --git a/doc/common-error-messages.rst b/doc/common-error-messages.rst index e9582730194..ebb9f733abd 100644 --- a/doc/common-error-messages.rst +++ b/doc/common-error-messages.rst @@ -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`_. \ No newline at end of file diff --git a/doc/test.rst b/doc/test.rst index b9027de008b..680e2821676 100644 --- a/doc/test.rst +++ b/doc/test.rst @@ -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 --------------------- diff --git a/test-core.ini b/test-core.ini index a9a05ae1270..7d9d4d6db54 100644 --- a/test-core.ini +++ b/test-core.ini @@ -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 so we can check that html is *not* escaped ckan.template_head_end = @@ -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 diff --git a/test.ini b/test.ini index ac94d5ba89c..4578a15b255 100644 --- a/test.ini +++ b/test.ini @@ -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