allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jetm...@apache.org
Subject [15/23] git commit: [#7278] ticket:612 Tests for search_projects method
Date Wed, 20 Aug 2014 07:10:54 GMT
[#7278] ticket:612 Tests for search_projects method


Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/1e1f6b57
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/1e1f6b57
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/1e1f6b57

Branch: refs/heads/je/42cc_7278
Commit: 1e1f6b57bb628771410679450e74988f1d3a339f
Parents: b3b378f
Author: Igor Bondarenko <jetmind2@gmail.com>
Authored: Fri Aug 1 17:18:52 2014 +0300
Committer: Igor Bondarenko <jetmind2@gmail.com>
Committed: Tue Aug 19 12:31:51 2014 +0000

----------------------------------------------------------------------
 Allura/allura/lib/search.py           |  4 ++--
 Allura/allura/tests/unit/test_solr.py | 13 +++++++++++++
 2 files changed, 15 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/1e1f6b57/Allura/allura/lib/search.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/search.py b/Allura/allura/lib/search.py
index 392e3c7..c0f45cc 100644
--- a/Allura/allura/lib/search.py
+++ b/Allura/allura/lib/search.py
@@ -159,7 +159,7 @@ def search_artifact(atype, q, history=False, rows=10, short_timeout=False,
filte
     return search(q, fq=fq, rows=rows, short_timeout=short_timeout, ignore_errors=False,
**kw)
 
 
-def search_projects(q, field, rows=10, short_timeout=False, **kw):
+def search_projects(q, field, **kw):
     """Performs SOLR search for a project.
 
     Raises SearchError if SOLR returns an error.
@@ -177,7 +177,7 @@ def search_projects(q, field, rows=10, short_timeout=False, **kw):
         # construct query for a specific selected field
         q = p.translate_query(u'%s:"%s"' % (field, q), fields)
     fq = [u'type_s:Project']
-    return search(q, fq=fq, rows=rows, short_timeout=short_timeout, ignore_errors=False,
**kw)
+    return search(q, fq=fq, ignore_errors=False, **kw)
 
 
 def search_app(q='', fq=None, app=True, **kw):

http://git-wip-us.apache.org/repos/asf/allura/blob/1e1f6b57/Allura/allura/tests/unit/test_solr.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/unit/test_solr.py b/Allura/allura/tests/unit/test_solr.py
index 0ee5b13..7e104d1 100644
--- a/Allura/allura/tests/unit/test_solr.py
+++ b/Allura/allura/tests/unit/test_solr.py
@@ -91,6 +91,19 @@ class TestSolr(unittest.TestCase):
         solr.search('bar', kw='kw')
         solr.query_server.search.assert_called_once_with('bar', kw='kw')
 
+    @mock.patch('allura.lib.search.search')
+    def test_search_projects(self, search):
+        from allura.lib.search import search_projects
+        fq = ['type_s:Project']
+        search_projects('test', 'shortname', rows=25)
+        search.assert_called_once_with(
+            'shortname_s:"test"', fq=fq, ignore_errors=False, rows=25)
+
+        search.reset_mock()
+        search_projects('shortname:test || shortname:test2', '__custom__')
+        search.assert_called_once_with(
+            'shortname_s:test || shortname_s:test2', fq=fq, ignore_errors=False)
+
 
 class TestSearchIndexable(unittest.TestCase):
 


Mime
View raw message