summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMarc Abonce Seguin <marc-abonce@mailbox.org>2019-07-29 21:25:05 -0700
committerMarc Abonce Seguin <marc-abonce@mailbox.org>2020-11-02 20:04:03 -0700
commit8d71420b4511fdac63c39f33d93c7add1ea7716d (patch)
tree14f3e1e9cf815cf5cc301fb1699cd54816adfc25 /tests
parent45f58a4a2a0b89f4b416c28ea769139b16f6436d (diff)
downloadsearxng-8d71420b4511fdac63c39f33d93c7add1ea7716d.tar.gz
searxng-8d71420b4511fdac63c39f33d93c7add1ea7716d.zip
[mod] separate index and search routes
This makes it easier to separately handle search and index requests from a web server or from a reverse proxy. If a request to index contains a query, a permanent redirect HTTP response is returned. This should give some level of backwards compatibility for users that have set a searx instance in their browser's search bar.
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/test_webapp.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/unit/test_webapp.py b/tests/unit/test_webapp.py
index 7dd465898..08a266931 100644
--- a/tests/unit/test_webapp.py
+++ b/tests/unit/test_webapp.py
@@ -77,6 +77,11 @@ class ViewsTestCase(SearxTestCase):
def test_index_html(self):
result = self.app.post('/', data={'q': 'test'})
+ self.assertEqual(result.status_code, 308)
+
+ def test_search_html(self):
+ result = self.app.post('/search', data={'q': 'test'})
+
self.assertIn(
b'<h3 class="result_title"><img width="14" height="14" class="favicon" src="/static/themes/legacy/img/icons/icon_youtube.ico" alt="youtube" /><a href="http://second.test.xyz" rel="noreferrer">Second <span class="highlight">Test</span></a></h3>', # noqa
result.data
@@ -88,7 +93,10 @@ class ViewsTestCase(SearxTestCase):
def test_index_json(self):
result = self.app.post('/', data={'q': 'test', 'format': 'json'})
+ self.assertEqual(result.status_code, 308)
+ def test_search_json(self):
+ result = self.app.post('/search', data={'q': 'test', 'format': 'json'})
result_dict = json.loads(result.data.decode())
self.assertEqual('test', result_dict['query'])
@@ -98,6 +106,10 @@ class ViewsTestCase(SearxTestCase):
def test_index_csv(self):
result = self.app.post('/', data={'q': 'test', 'format': 'csv'})
+ self.assertEqual(result.status_code, 308)
+
+ def test_search_csv(self):
+ result = self.app.post('/search', data={'q': 'test', 'format': 'csv'})
self.assertEqual(
b'title,url,content,host,engine,score,type\r\n'
@@ -108,6 +120,10 @@ class ViewsTestCase(SearxTestCase):
def test_index_rss(self):
result = self.app.post('/', data={'q': 'test', 'format': 'rss'})
+ self.assertEqual(result.status_code, 308)
+
+ def test_index_rss(self):
+ result = self.app.post('/search', data={'q': 'test', 'format': 'rss'})
self.assertIn(
b'<description>Search results for "test" - searx</description>',