summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAlexandre Flament <alex@al-f.net>2020-11-06 12:11:52 +0100
committerAlexandre Flament <alex@al-f.net>2020-11-06 12:11:52 +0100
commitb3a3ccf2dbf93b26c506904f53d03e5f11398aab (patch)
tree08d8bb6bbd2633bb7ad9788ba2d0c69dd56ad917 /tests
parentc03e4c86bc49d6ef4664c038066d9f1c16e7dafc (diff)
downloadsearxng-b3a3ccf2dbf93b26c506904f53d03e5f11398aab.tar.gz
searxng-b3a3ccf2dbf93b26c506904f53d03e5f11398aab.zip
[fix] fix of / and /search
* URL / : the index page displayed the selected or the default category. * URL / : when the q parameter is set using the URL, the redirect includes the URL query. * URL /search : an empty query doesn't raise an exception.
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/test_webapp.py25
1 files changed, 24 insertions, 1 deletions
diff --git a/tests/unit/test_webapp.py b/tests/unit/test_webapp.py
index 08a266931..75a968ad8 100644
--- a/tests/unit/test_webapp.py
+++ b/tests/unit/test_webapp.py
@@ -75,9 +75,32 @@ class ViewsTestCase(SearxTestCase):
self.assertEqual(result.status_code, 200)
self.assertIn(b'<div class="title"><h1>searx</h1></div>', result.data)
- def test_index_html(self):
+ def test_index_html_post(self):
result = self.app.post('/', data={'q': 'test'})
self.assertEqual(result.status_code, 308)
+ self.assertEqual(result.location, 'http://localhost/search')
+
+ def test_index_html_get(self):
+ result = self.app.post('/?q=test')
+ self.assertEqual(result.status_code, 308)
+ self.assertEqual(result.location, 'http://localhost/search?q=test')
+
+ def test_search_empty_html(self):
+ result = self.app.post('/search', data={'q': ''})
+ self.assertEqual(result.status_code, 200)
+ self.assertIn(b'<div class="title"><h1>searx</h1></div>', result.data)
+
+ def test_search_empty_json(self):
+ result = self.app.post('/search', data={'q': '', 'format': 'json'})
+ self.assertEqual(result.status_code, 400)
+
+ def test_search_empty_csv(self):
+ result = self.app.post('/search', data={'q': '', 'format': 'csv'})
+ self.assertEqual(result.status_code, 400)
+
+ def test_search_empty_rss(self):
+ result = self.app.post('/search', data={'q': '', 'format': 'rss'})
+ self.assertEqual(result.status_code, 400)
def test_search_html(self):
result = self.app.post('/search', data={'q': 'test'})