[ckan-changes] commit/ckan: 2 new changesets
Bitbucket
commits-noreply at bitbucket.org
Tue Aug 23 10:34:41 UTC 2011
2 new changesets in ckan:
http://bitbucket.org/okfn/ckan/changeset/32e61778178a/
changeset: 32e61778178a
branch: feature-1275-solr-search
user: John Glover
date: 2011-08-23 11:50:14
summary: [solr] Fix some problems with sqlite tests (skip search related tests)
affected #: 4 files (354 bytes)
--- a/ckan/tests/__init__.py Mon Aug 22 17:50:47 2011 +0100
+++ b/ckan/tests/__init__.py Tue Aug 23 10:50:14 2011 +0100
@@ -365,6 +365,12 @@
def list(cls):
return [model.Package.get(pkg_index.package_id).name for pkg_index in model.Session.query(model.PackageSearch)]
+def setup_test_search_index():
+ from ckan import plugins
+ if not is_search_supported():
+ raise SkipTest("Search not supported")
+ search.clear()
+ plugins.load('synchronous_search')
def is_search_supported():
supported_db = "sqlite" not in config.get('sqlalchemy.url')
--- a/ckan/tests/functional/test_authz.py Mon Aug 22 17:50:47 2011 +0100
+++ b/ckan/tests/functional/test_authz.py Tue Aug 23 10:50:14 2011 +0100
@@ -6,7 +6,7 @@
import ckan.model as model
from ckan import plugins
-from ckan.tests import TestController, url_for
+from ckan.tests import TestController, url_for, setup_test_search_index
from ckan.lib.base import *
import ckan.lib.search as search
from ckan.lib.create_test_data import CreateTestData
@@ -22,8 +22,7 @@
@classmethod
def setup_class(self):
- search.clear()
- plugins.load('synchronous_search')
+ setup_test_search_index()
self._create_test_data()
model.Session.remove()
@@ -597,9 +596,9 @@
model.Session.delete(role_action)
model.repo.commit_and_remove()
+ setup_test_search_index()
TestUsage._create_test_data()
model.Session.remove()
- search.rebuild()
self.user_name = TestUsage.mrloggedin.name.encode('utf-8')
def _check_logged_in_users_authorized_only(self, offset):
--- a/ckan/tests/functional/test_package.py Mon Aug 22 17:50:47 2011 +0100
+++ b/ckan/tests/functional/test_package.py Tue Aug 23 10:50:14 2011 +0100
@@ -10,7 +10,7 @@
from nose.tools import assert_equal
from ckan.tests import *
-from ckan.tests import search_related, is_search_supported
+from ckan.tests import search_related, setup_test_search_index
from ckan.tests.html_check import HtmlCheckMethods
from ckan.tests.pylons_controller import PylonsTestCase
from base import FunctionalTestCase
@@ -264,12 +264,8 @@
@classmethod
def setup_class(cls):
- if not is_search_supported():
- raise SkipTest("Search not supported")
-
PylonsTestCase.setup_class()
- search.clear()
- plugins.load('synchronous_search')
+ setup_test_search_index()
CreateTestData.create()
@classmethod
--- a/ckan/tests/lib/test_solr_search_index.py Mon Aug 22 17:50:47 2011 +0100
+++ b/ckan/tests/lib/test_solr_search_index.py Tue Aug 23 10:50:14 2011 +0100
@@ -2,16 +2,12 @@
from pylons import config
from ckan import model
import ckan.lib.search as search
-from ckan.tests import TestController, CreateTestData
+from ckan.tests import TestController, CreateTestData, setup_test_search_index
class TestSolrConfig(TestController):
"""
Make sure that solr is enabled for this ckan instance.
"""
- @classmethod
- def setup_class(cls):
- config['search_backend'] = 'solr'
-
def test_solr_url_exists(self):
assert config.get('solr_url')
# solr.SolrConnection will throw an exception if it can't connect
@@ -25,7 +21,7 @@
"""
@classmethod
def setup_class(cls):
- config['search_backend'] = 'solr'
+ setup_test_search_index()
CreateTestData.create()
cls.solr = solr.SolrConnection(config.get('solr_url'))
cls.fq = " +site_id:\"%s\" " % config.get('ckan.site_id')
@@ -75,6 +71,7 @@
class TestSolrSearch:
@classmethod
def setup_class(cls):
+ setup_test_search_index()
CreateTestData.create_search_test_data()
cls.solr = solr.SolrConnection(config.get('solr_url'))
cls.fq = " +site_id:\"%s\" " % config.get('ckan.site_id')
http://bitbucket.org/okfn/ckan/changeset/6703306b24cc/
changeset: 6703306b24cc
branch: feature-1275-solr-search
user: John Glover
date: 2011-08-23 12:20:29
summary: [solr] Skip remaining search tests when using sqlite
affected #: 3 files (188 bytes)
--- a/ckan/tests/functional/api/test_package_search.py Tue Aug 23 10:50:14 2011 +0100
+++ b/ckan/tests/functional/api/test_package_search.py Tue Aug 23 11:20:29 2011 +0100
@@ -2,7 +2,7 @@
from ckan import plugins
import ckan.lib.search as search
-from ckan.tests import is_search_supported
+from ckan.tests import setup_test_search_index
from ckan.tests.functional.api.base import *
from ckan.tests import TestController as ControllerTestCase
from ckan.controllers.api import ApiController
@@ -12,12 +12,7 @@
@classmethod
def setup_class(self):
- if not is_search_supported():
- import nose
- raise nose.SkipTest
-
- search.clear()
- plugins.load('synchronous_search')
+ setup_test_search_index()
CreateTestData.create()
self.package_fixture_data = {
'name' : u'testpkg',
--- a/ckan/tests/lib/test_solr_package_search.py Tue Aug 23 10:50:14 2011 +0100
+++ b/ckan/tests/lib/test_solr_package_search.py Tue Aug 23 11:20:29 2011 +0100
@@ -1,4 +1,4 @@
-from ckan.tests import TestController, CreateTestData
+from ckan.tests import TestController, CreateTestData, setup_test_search_index
from ckan import model
import ckan.lib.search as search
@@ -10,6 +10,7 @@
@classmethod
def setup_class(cls):
model.Session.remove()
+ setup_test_search_index()
CreateTestData.create_search_test_data()
# now remove a tag so we can test search with deleted tags
model.repo.new_revision()
@@ -19,12 +20,11 @@
idx = [t.name for t in gils.tags].index(cls.tagname)
del gils.tags[idx]
model.repo.commit_and_remove()
- search.rebuild()
@classmethod
def teardown_class(cls):
model.repo.rebuild_db()
- search.index_for('Package').clear()
+ search.clear()
def _pkg_names(self, result):
return ' '.join(result['results'])
@@ -224,13 +224,13 @@
class TestSearchOverall(TestController):
@classmethod
def setup_class(cls):
+ setup_test_search_index()
CreateTestData.create()
- search.rebuild()
@classmethod
def teardown_class(cls):
model.repo.rebuild_db()
- search.index_for('Package').clear()
+ search.clear()
def _check_search_results(self, terms, expected_count, expected_packages=[], only_open=False, only_downloadable=False):
options = search.QueryOptions()
@@ -262,6 +262,7 @@
class TestGeographicCoverage(TestController):
@classmethod
def setup_class(cls):
+ setup_test_search_index()
init_data = [
{'name':'eng',
'extras':{'geographic_coverage':'100000: England'},},
@@ -275,12 +276,11 @@
'extras':{'geographic_coverage':'000000:'},},
]
CreateTestData.create_arbitrary(init_data)
- search.rebuild()
@classmethod
def teardown_class(self):
model.repo.rebuild_db()
- search.index_for('Package').clear()
+ search.clear()
def _do_search(self, q, expected_pkgs, count=None):
options = search.QueryOptions()
@@ -322,6 +322,7 @@
class TestExtraFields(TestController):
@classmethod
def setup_class(cls):
+ setup_test_search_index()
init_data = [
{'name':'a',
'extras':{'department':'abc',
@@ -335,12 +336,11 @@
'extras':{'department':''},},
]
CreateTestData.create_arbitrary(init_data)
- search.rebuild()
@classmethod
def teardown_class(self):
model.repo.rebuild_db()
- search.index_for('Package').clear()
+ search.clear()
def _do_search(self, department, expected_pkgs, count=None):
result = search.query_for(model.Package).run(fields={'department': department})
@@ -369,6 +369,7 @@
class TestRank(TestController):
@classmethod
def setup_class(cls):
+ setup_test_search_index()
init_data = [{'name':u'test1-penguin-canary',
'tags':u'canary goose squirrel wombat wombat'},
{'name':u'test2-squirrel-squirrel-canary-goose',
@@ -379,12 +380,11 @@
u'test1-penguin-canary',
u'test2-squirrel-squirrel-canary-goose'
]
- search.rebuild()
@classmethod
def teardown_class(self):
model.repo.rebuild_db()
- search.index_for('Package').clear()
+ search.clear()
def _do_search(self, q, wanted_results):
options = search.QueryOptions()
--- a/ckan/tests/lib/test_solr_package_search_synchronous_update.py Tue Aug 23 10:50:14 2011 +0100
+++ b/ckan/tests/lib/test_solr_package_search_synchronous_update.py Tue Aug 23 11:20:29 2011 +0100
@@ -1,7 +1,7 @@
from pylons import config
from ckan import plugins, model
import ckan.lib.search as search
-from ckan.tests import CreateTestData
+from ckan.tests import CreateTestData, setup_test_search_index
from test_solr_package_search import TestSearchOverall
class TestSearchOverallWithSynchronousIndexing(TestSearchOverall):
@@ -10,13 +10,12 @@
@classmethod
def setup_class(cls):
+ setup_test_search_index()
# Force a garbage collection to trigger issue #695
import gc
gc.collect()
CreateTestData.create()
- search.rebuild()
- plugins.load('synchronous_search')
cls.new_pkg_dict = {
"name": "council-owned-litter-bins",
@@ -51,7 +50,7 @@
@classmethod
def teardown_class(cls):
model.repo.rebuild_db()
- search.index_for('Package').clear()
+ search.clear()
def _create_package(self, package=None):
rev = model.repo.new_revision()
Repository URL: https://bitbucket.org/okfn/ckan/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
More information about the ckan-changes
mailing list