allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [04/20] git commit: [#7257] ticket:562 Added tests for 'add_project' index task
Date Wed, 21 May 2014 14:44:52 GMT
[#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/6c0fa249
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/6c0fa249
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/6c0fa249

Branch: refs/heads/master
Commit: 6c0fa24903ab0e99621f153c365dd0f329cd90da
Parents: f4b70d3
Author: Ferens Dmitriy <ferensdima@gmail.com>
Authored: Wed Mar 26 17:16:18 2014 +0200
Committer: Dave Brondsema <dbrondsema@slashdotmedia.com>
Committed: Wed May 21 14:44:19 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/6c0fa249/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/6c0fa249/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/6c0fa249/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


Mime
View raw message