summaryrefslogtreecommitdiff
path: root/tests/unit
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unit')
-rw-r--r--tests/unit/test_search.py21
-rw-r--r--tests/unit/test_webapp.py3
2 files changed, 23 insertions, 1 deletions
diff --git a/tests/unit/test_search.py b/tests/unit/test_search.py
index 18c221954..ca9fe862a 100644
--- a/tests/unit/test_search.py
+++ b/tests/unit/test_search.py
@@ -110,3 +110,24 @@ class SearchTestCase(SearxTestCase):
search = searx.search.Search(search_query)
results = search.search()
self.assertEquals(results.results_length(), 1)
+
+ def test_external_bang(self):
+ search_query = searx.query.SearchQuery('yes yes',
+ [{'category': 'general', 'name': PUBLIC_ENGINE_NAME}],
+ ['general'], 'en-US', SAFESEARCH, PAGENO, None, None,
+ preferences=Preferences(['oscar'], ['general'], engines, [],),
+ external_bang="yt")
+ search = searx.search.Search(search_query)
+ results = search.search()
+ # For checking if the user redirected with the youtube external bang
+ self.assertTrue(results.redirect_url is not None)
+
+ search_query = searx.query.SearchQuery('youtube never gonna give you up',
+ [{'category': 'general', 'name': PUBLIC_ENGINE_NAME}],
+ ['general'], 'en-US', SAFESEARCH, PAGENO, None, None,
+ preferences=Preferences(['oscar'], ['general'], engines, []),)
+
+ search = searx.search.Search(search_query)
+ results = search.search()
+ # This should not redirect
+ self.assertTrue(results.redirect_url is None)
diff --git a/tests/unit/test_webapp.py b/tests/unit/test_webapp.py
index f15e3c92c..8eed607e3 100644
--- a/tests/unit/test_webapp.py
+++ b/tests/unit/test_webapp.py
@@ -56,7 +56,8 @@ class ViewsTestCase(SearxTestCase):
results=test_results,
results_number=lambda: 3,
results_length=lambda: len(test_results),
- get_timings=lambda: timings)
+ get_timings=lambda: timings,
+ redirect_url=None)
self.setattr4test(Search, 'search', search_mock)