diff options
author | Alexandre Flament <alex@al-f.net> | 2020-11-14 13:23:03 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-14 13:23:03 +0100 |
commit | ebed1461bc4b635b6dde5d99e53dada6711a6d7a (patch) | |
tree | b86de713b397146fb4929523a1588ccd96f43caa /tests | |
parent | 20c95712ead0e538ecc7fa17735c5acc3015840d (diff) | |
parent | b3a3ccf2dbf93b26c506904f53d03e5f11398aab (diff) | |
download | searxng-ebed1461bc4b635b6dde5d99e53dada6711a6d7a.tar.gz searxng-ebed1461bc4b635b6dde5d99e53dada6711a6d7a.zip |
Merge pull request #2300 from dalf/fix-webapp-index
[fix] fix of / and /search
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unit/test_webapp.py | 25 |
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'}) |