mirror of
https://github.com/sissbruecker/linkding.git
synced 2025-08-08 19:28:29 +02:00
Add opensearch declaration (#1058)
* feat: Add opensearch declaration * cleanup --------- Co-authored-by: Johannes Zorn <johannes.zorn@zollsoft.com> Co-authored-by: Sascha Ißbrücker <sascha.issbruecker@gmail.com>
This commit is contained in:
25
bookmarks/tests/test_opensearch_view.py
Normal file
25
bookmarks/tests/test_opensearch_view.py
Normal file
@@ -0,0 +1,25 @@
|
||||
from django.test import TestCase
|
||||
from django.urls import reverse
|
||||
|
||||
|
||||
class OpenSearchViewTestCase(TestCase):
|
||||
|
||||
def test_opensearch_configuration(self):
|
||||
response = self.client.get(reverse("linkding:opensearch"))
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertEqual(
|
||||
response["content-type"], "application/opensearchdescription+xml"
|
||||
)
|
||||
|
||||
base_url = "http://testserver"
|
||||
expected_content = f"""
|
||||
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/" xmlns:moz="http://www.mozilla.org/2006/browser/search/">
|
||||
<ShortName>Linkding</ShortName>
|
||||
<Description>Linkding</Description>
|
||||
<InputEncoding>UTF-8</InputEncoding>
|
||||
<Image width="16" height="16" type="image/x-icon">{base_url}/static/favicon.ico</Image>
|
||||
<Url type="text/html" template="{base_url}/bookmarks?client=opensearch&q={{searchTerms}}"/>
|
||||
</OpenSearchDescription>
|
||||
"""
|
||||
content = response.content.decode()
|
||||
self.assertXMLEqual(content, expected_content)
|
Reference in New Issue
Block a user