incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [6/7] git commit: [#2835] ticket:289 Test wiki search
Date Tue, 26 Mar 2013 21:13:53 GMT
[#2835] ticket:289 Test wiki search


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

Branch: refs/heads/db/42cc_2835_content_preview
Commit: 218f4b4c5277d2c0f61901e61b71f06722c3b675
Parents: 1b38382
Author: Igor Bondarenko <jetmind2@gmail.com>
Authored: Tue Mar 19 13:02:45 2013 +0000
Committer: Dave Brondsema <dbrondsema@geek.net>
Committed: Tue Mar 26 21:13:22 2013 +0000

----------------------------------------------------------------------
 ForgeWiki/forgewiki/tests/functional/test_root.py |   47 +++++++++++++++-
 1 files changed, 46 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/218f4b4c/ForgeWiki/forgewiki/tests/functional/test_root.py
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/tests/functional/test_root.py b/ForgeWiki/forgewiki/tests/functional/test_root.py
index 7c98499..be4185d 100644
--- a/ForgeWiki/forgewiki/tests/functional/test_root.py
+++ b/ForgeWiki/forgewiki/tests/functional/test_root.py
@@ -3,7 +3,7 @@ import os
 import Image, StringIO
 import allura
 
-from nose.tools import assert_true, assert_equal
+from nose.tools import assert_true, assert_equal, assert_in
 
 from ming.orm.ormsession import ThreadLocalORMSession
 from mock import patch
@@ -62,6 +62,51 @@ class TestRootController(TestController):
         response = self.app.get('/wiki/search?q=tést')
         assert 'Search wiki: tést' in response
 
+    @patch('forgewiki.wiki_main.search')
+    def test_search(self, search):
+        r = self.app.get('/wiki/search?q=test')
+        assert_in('<a href="/wiki/search?q=test&amp;sort=score+asc" class="strong">relevance</a>',
r)
+        assert_in('<a href="/wiki/search?q=test&amp;sort=mod_date_dt+desc" class="">date</a>',
r)
+
+        p = M.Project.query.get(shortname='test')
+        r = self.app.get('/wiki/search?q=test&sort=score+asc')
+        solr_query = {
+            'short_timeout': True,
+            'ignore_errors': False,
+            'rows': 25,
+            'start': 0,
+            'qt': 'dismax',
+            'qf': 'title^2 text',
+            'pf': 'title^2 text',
+            'fq': [
+                'project_id_s:%s'  % p._id,
+                'mount_point_s:wiki',
+                '-deleted_b:true',
+                'type_s:("WikiPage" OR "WikiPage Snapshot")',
+                'is_history_b:False',
+            ],
+            'hl': 'true',
+            'hl.simple.pre': '<strong>',
+            'hl.simple.post': '</strong>',
+            'sort': 'score asc',
+        }
+        search.assert_called_with('test', **solr_query)
+
+        r = self.app.get('/wiki/search?q=test&search_comments=on&history=on&sort=mod_date_dt+desc')
+        solr_query['fq'][3] = 'type_s:("WikiPage" OR "WikiPage Snapshot" OR "Post")'
+        solr_query['fq'].remove('is_history_b:False')
+        solr_query['sort'] = 'mod_date_dt desc'
+        search.assert_called_with('test', **solr_query)
+
+        r = self.app.get('/wiki/search?q=test&parser=standard')
+        solr_query['sort'] = 'score desc'
+        solr_query['fq'][3] = 'type_s:("WikiPage" OR "WikiPage Snapshot")'
+        solr_query['fq'].append('is_history_b:False')
+        solr_query.pop('qt')
+        solr_query.pop('qf')
+        solr_query.pop('pf')
+        search.assert_called_with('test', **solr_query)
+
     def test_page_index(self):
         response = self.app.get('/wiki/tést/')
         assert 'tést' in response.follow()


Mime
View raw message