[ckan-changes] commit/ckanext-solr: 2 new changesets
Bitbucket
commits-noreply at bitbucket.org
Wed Aug 10 16:57:09 UTC 2011
2 new changesets in ckanext-solr:
http://bitbucket.org/okfn/ckanext-solr/changeset/6dcc84416990/
changeset: 6dcc84416990
user: John Glover
date: 2011-08-10 18:54:05
summary: update ignore list
affected #: 1 file (22 bytes)
--- a/.hgignore Wed Aug 03 13:18:38 2011 +0200
+++ b/.hgignore Wed Aug 10 17:54:05 2011 +0100
@@ -4,3 +4,5 @@
*.swp
*.swo
*.egg-info
+*.DS_Store
+tests/*.db
http://bitbucket.org/okfn/ckanext-solr/changeset/5847a66db1d5/
changeset: 5847a66db1d5
user: John Glover
date: 2011-08-10 18:54:18
summary: Add first search index tests
affected #: 4 files (6.1 KB)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/setup.cfg Wed Aug 10 17:54:18 2011 +0100
@@ -0,0 +1,2 @@
+[nosetests]
+with-pylons=test.ini
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test.ini Wed Aug 10 17:54:18 2011 +0100
@@ -0,0 +1,127 @@
+[DEFAULT]
+debug = false
+
+[server:main]
+use = egg:Paste#http
+host = 0.0.0.0
+port = 5000
+
+[app:main]
+use = egg:ckan
+
+ckan.site_id = solr_test
+search_backend = solr
+solr_url = http://127.0.0.1:8983/solr
+
+# disable this so we can test all types of indexing
+ckan.build_search_index_synchronously = false
+
+# Here we hard-code the database and a flag to make default tests run fast.
+faster_db_test_hacks = True
+sqlalchemy.url = sqlite:///%(here)s/tests/test.db
+
+ckan.cache_validation_enabled = True
+ckan.cache_enabled = False
+ckan.cache.default_expires = 200
+
+package_form = standard
+carrot_messaging_library = queue
+ckan.site_url = http://test.ckan.net
+package_new_return_url = http://localhost/package/<NAME>?test=new
+package_edit_return_url = http://localhost/package/<NAME>?test=edit
+
+ckan.extra_resource_fields = alt_url
+
+# Add additional test specific configuration options as necessary.
+auth.blacklist = 83.222.23.234
+
+# Change API key HTTP header to something non-standard.
+apikey_header_name = X-Non-Standard-CKAN-API-Key
+
+# use <strong> so we can check that html is *not* escaped
+ckan.template_footer_end = <strong>TEST TEMPLATE_FOOTER_END TEST</strong>
+
+full_stack = true
+cache_dir = %(here)s/data
+beaker.session.key = ckan
+beaker.session.secret = l5Y9J+JZsnXHLd+9Df+W+Inaf
+app_instance_uuid = {ba835a3e-76d8-4e0c-b71f-1baafb2d11dc}
+
+# repoze.who config
+who.config_file = %(here)s/who.ini
+who.log_level = warning
+who.log_file = %(cache_dir)s/who_log.ini
+
+# cache to persistent files
+beaker.cache.type = file
+
+# CKAN QoS monitoring
+ckan.enable_call_timing = false
+
+# Package form to use
+package_form = standard
+
+## Update the search index synchronously (i.e. in-process rather than
+## out-of-process as would be case if using AMQP framework)
+## Set to false to disable, true to enable
+## Default enabled (and enabled if option entirely absent)
+## NOTE this is mutually exclusive with ckan.async_notifier
+ckan.build_search_index_synchronously = true
+
+## Title of site (using in several places including templates and <title> tag
+ckan.site_title = CKAN
+
+## Logo image to use (replaces site_title string on front page if defined)
+ckan.site_logo = http://assets.okfn.org/p/ckan/img/ckan_logo_largetext.png
+
+## Site tagline / description (used on front page)
+ckan.site_description =
+
+## Used in creating some absolute urls (such as rss feeds, css files) and
+## dump filenames
+ckan.site_url =
+
+## Favicon (default is the CKAN software favicon)
+ckan.favicon = http://assets.okfn.org/p/ckan/img/ckan.ico
+
+# Directory for logs (produced by cron scripts associated with ckan)
+ckan.log_dir = %(here)s/log
+
+# Directory for JSON/CSV dumps (must match setting in apache config)
+ckan.dump_dir = %(here)s/dump
+
+# Directory for SQL database backups
+ckan.backup_dir = %(here)s/backup
+
+# Logging configuration
+[loggers]
+keys = root, ckan, sqlalchemy
+
+[handlers]
+keys = console
+
+[formatters]
+keys = generic
+
+[logger_root]
+level = INFO
+handlers = console
+
+[logger_ckan]
+qualname = ckan
+handlers =
+level = INFO
+
+[logger_sqlalchemy]
+handlers =
+qualname = sqlalchemy.engine
+level = WARN
+
+[handler_console]
+class = StreamHandler
+args = (sys.stdout,)
+level = NOTSET
+formatter = generic
+
+[formatter_generic]
+format = %(asctime)s %(levelname)-5.5s [%(name)s] %(message)s
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test_search_index.py Wed Aug 10 17:54:18 2011 +0100
@@ -0,0 +1,77 @@
+import time
+import sqlalchemy as sa
+import solr
+from pylons import config
+from ckan.tests import *
+from ckan import model
+import ckan.lib.search as search
+from ckanext.solr.backend import SolrSearchBackend
+
+class TestSolrConfig(TestController):
+ """
+ Make sure that solr is enabled for this ckan instance.
+ """
+ def test_solr_backend_selected(self):
+ assert config.get('search_backend') == 'solr',\
+ config.get('search_backend')
+
+ def test_solr_backend_returned(self):
+ assert isinstance(search.get_backend(), SolrSearchBackend),\
+ search.get_backend()
+
+ def test_solr_url_exists(self):
+ assert config.get('solr_url')
+ # solr.SolrConnection will throw an exception if it can't connect
+ solr.SolrConnection(config.get('solr_url'))
+
+
+class TestSearchIndex(TestController):
+ """
+ Tests that a package is indexed when the packagenotification is
+ received by the indexer.
+ """
+ @classmethod
+ def setup_class(cls):
+ CreateTestData.create()
+ cls.solr = solr.SolrConnection(config.get('solr_url'))
+
+ @classmethod
+ def teardown_class(cls):
+ model.repo.rebuild_db()
+
+ def teardown(self):
+ # clear the search index after every test
+ search.get_backend().index_for('Package').clear()
+
+ def test_index(self):
+ pkg_dict = {
+ 'id': u'penguin-id',
+ 'title': u'penguin',
+ 'state': u'active'
+ }
+ search.dispatch_by_operation('Package', pkg_dict, 'new')
+ response = self.solr.query('title:penguin')
+ assert len(response) == 1, len(response)
+ assert response.results[0]['title'] == 'penguin'
+
+ def test_no_state_not_indexed(self):
+ pkg_dict = {
+ 'title': 'penguin'
+ }
+ search.dispatch_by_operation('Package', pkg_dict, 'new')
+ response = self.solr.query('title:penguin')
+ assert len(response) == 0, len(response)
+
+ def test_index_clear(self):
+ pkg_dict = {
+ 'id': u'penguin-id',
+ 'title': u'penguin',
+ 'state': u'active'
+ }
+ search.dispatch_by_operation('Package', pkg_dict, 'new')
+ response = self.solr.query('title:penguin')
+ assert len(response) == 1, len(response)
+ search.get_backend().index_for('Package').clear()
+ response = self.solr.query('title:penguin')
+ assert len(response) == 0
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/who.ini Wed Aug 10 17:54:18 2011 +0100
@@ -0,0 +1,20 @@
+[plugin:friendlyform]
+use = repoze.who.plugins.friendlyform:FriendlyFormPlugin
+login_form_url= /user/login
+login_handler_path = /login_generic
+logout_handler_path = /user/logout
+rememberer_name = auth_tkt
+post_login_url = /user/logged_in
+post_logout_url = /user/logged_out
+
+[general]
+request_classifier = repoze.who.classifiers:default_request_classifier
+
+[identifiers]
+plugins = friendlyform;browser
+
+[authenticators]
+plugins = ckan.lib.authenticator:UsernamePasswordAuthenticator
+
+[challengers]
+plugins = friendlyform;browser
Repository URL: https://bitbucket.org/okfn/ckanext-solr/
--
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