You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2014/05/09 23:42:24 UTC
[04/18] git commit: [#7257] ticket:562 Added tests for 'add_project'
index task
[#7257] ticket:562 Added tests for 'add_project' index task
Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/81cbc1d5
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/81cbc1d5
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/81cbc1d5
Branch: refs/heads/db/7257
Commit: 81cbc1d580c6a61496f28a74702e6d66f7dabd55
Parents: cea821f
Author: Ferens Dmitriy <fe...@gmail.com>
Authored: Wed Mar 26 17:16:18 2014 +0200
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Fri May 9 18:56:46 2014 +0000
----------------------------------------------------------------------
Allura/allura/lib/search.py | 2 +-
Allura/allura/tasks/index_tasks.py | 12 ++++++------
Allura/allura/tests/test_tasks.py | 7 +++++++
3 files changed, 14 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/allura/blob/81cbc1d5/Allura/allura/lib/search.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/search.py b/Allura/allura/lib/search.py
index 08ad1a5..27cc05e 100644
--- a/Allura/allura/lib/search.py
+++ b/Allura/allura/lib/search.py
@@ -89,7 +89,7 @@ class SearchIndexable(object):
return doc
def add_to_solr(self, solr_instance):
- solr_instance.add(self.solarize())
+ solr_instance.add([self.solarize()])
class SearchError(SolrError):
http://git-wip-us.apache.org/repos/asf/allura/blob/81cbc1d5/Allura/allura/tasks/index_tasks.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tasks/index_tasks.py b/Allura/allura/tasks/index_tasks.py
index d507e5e..bb54118 100644
--- a/Allura/allura/tasks/index_tasks.py
+++ b/Allura/allura/tasks/index_tasks.py
@@ -60,7 +60,7 @@ def add_artifacts(ref_ids, update_solr=True, update_refs=True, solr_hosts=None):
solr_updates = []
with _indexing_disabled(M.session.artifact_orm_session._get()):
for ref in M.ArtifactReference.query.find(dict(_id={'$in': ref_ids})):
- try:
+ # try:
artifact = ref.artifact
s = artifact.solarize()
if s is None:
@@ -72,12 +72,12 @@ def add_artifacts(ref_ids, update_solr=True, update_refs=True, solr_hosts=None):
continue
# Find shortlinks in the raw text, not the escaped html
# created by the `solarize()`.
- link_text = artifact.index().get('text', '')
+ link_text = artifact.index().get('text') or ''
shortlinks = find_shortlinks(link_text)
- ref.references = [link.ref_id for link in shortlinks)]
- except Exception:
- log.error('Error indexing artifact %s', ref._id)
- exceptions.append(sys.exc_info())
+ ref.references = [link.ref_id for link in shortlinks]
+ # except Exception:
+ # log.error('Error indexing artifact %s', ref._id)
+ # exceptions.append(sys.exc_info())
solr.add(solr_updates)
if len(exceptions) == 1:
http://git-wip-us.apache.org/repos/asf/allura/blob/81cbc1d5/Allura/allura/tests/test_tasks.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/test_tasks.py b/Allura/allura/tests/test_tasks.py
index ee8adf3..01df2c4 100644
--- a/Allura/allura/tests/test_tasks.py
+++ b/Allura/allura/tests/test_tasks.py
@@ -101,6 +101,13 @@ class TestIndexTasks(unittest.TestCase):
setup_basic_test()
setup_global_objects()
+ def test_add_project(self):
+ old_solr_size = len(g.solr.db)
+ project = M.Project.query.find().first()
+ index_tasks.add_project(project._id)
+ new_solr_size = len(g.solr.db)
+ assert old_solr_size + 1 == new_solr_size
+
@td.with_wiki
def test_add_artifacts(self):
from allura.lib.search import find_shortlinks