2023-05-23 19:20:58 +00:00
|
|
|
from django.test import TestCase, override_settings
|
|
|
|
|
|
|
|
|
|
|
|
class MetadataViewTestCase(TestCase):
|
|
|
|
|
|
|
|
def test_default_manifest(self):
|
|
|
|
response = self.client.get("/manifest.json")
|
|
|
|
|
|
|
|
self.assertEqual(response.status_code, 200)
|
|
|
|
|
|
|
|
response_body = response.json()
|
|
|
|
expected_body = {
|
|
|
|
"short_name": "linkding",
|
2024-03-16 14:20:22 +00:00
|
|
|
"name": "linkding",
|
|
|
|
"description": "Self-hosted bookmark service",
|
2023-05-23 19:20:58 +00:00
|
|
|
"start_url": "bookmarks",
|
|
|
|
"display": "standalone",
|
2024-01-27 10:29:16 +00:00
|
|
|
"scope": "/",
|
2024-03-16 14:20:22 +00:00
|
|
|
"theme_color": "#5856e0",
|
|
|
|
"background_color": "#ffffff",
|
|
|
|
"icons": [
|
|
|
|
{
|
|
|
|
"src": "/static/logo.svg",
|
|
|
|
"type": "image/svg+xml",
|
|
|
|
"sizes": "512x512",
|
2024-03-24 10:50:02 +00:00
|
|
|
"purpose": "any",
|
2024-03-16 14:20:22 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"src": "/static/logo-512.png",
|
|
|
|
"type": "image/png",
|
|
|
|
"sizes": "512x512",
|
2024-03-24 10:50:02 +00:00
|
|
|
"purpose": "any",
|
2024-03-16 14:20:22 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"src": "/static/logo-192.png",
|
|
|
|
"type": "image/png",
|
|
|
|
"sizes": "192x192",
|
2024-03-24 10:50:02 +00:00
|
|
|
"purpose": "any",
|
2024-03-16 14:20:22 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"src": "/static/maskable-logo.svg",
|
|
|
|
"type": "image/svg+xml",
|
|
|
|
"sizes": "512x512",
|
2024-03-24 10:50:02 +00:00
|
|
|
"purpose": "maskable",
|
2024-03-16 14:20:22 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"src": "/static/maskable-logo-512.png",
|
|
|
|
"type": "image/png",
|
|
|
|
"sizes": "512x512",
|
2024-03-24 10:50:02 +00:00
|
|
|
"purpose": "maskable",
|
2024-03-16 14:20:22 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"src": "/static/maskable-logo-192.png",
|
|
|
|
"type": "image/png",
|
|
|
|
"sizes": "192x192",
|
2024-03-24 10:50:02 +00:00
|
|
|
"purpose": "maskable",
|
2024-03-16 14:20:22 +00:00
|
|
|
},
|
|
|
|
],
|
|
|
|
"shortcuts": [
|
|
|
|
{
|
|
|
|
"name": "Add bookmark",
|
|
|
|
"url": "/bookmarks/new",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "Archived",
|
|
|
|
"url": "/bookmarks/archived",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "Unread",
|
|
|
|
"url": "/bookmarks?unread=yes",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "Untagged",
|
|
|
|
"url": "/bookmarks?q=!untagged",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "Shared",
|
|
|
|
"url": "/bookmarks/shared",
|
2024-03-24 10:50:02 +00:00
|
|
|
},
|
2024-03-16 14:20:22 +00:00
|
|
|
],
|
|
|
|
"screenshots": [
|
|
|
|
{
|
|
|
|
"src": "/static/linkding-screenshot.png",
|
|
|
|
"type": "image/png",
|
|
|
|
"sizes": "2158x1160",
|
2024-03-24 10:50:02 +00:00
|
|
|
"form_factor": "wide",
|
2024-03-16 14:20:22 +00:00
|
|
|
}
|
|
|
|
],
|
|
|
|
"share_target": {
|
|
|
|
"action": "/bookmarks/new",
|
|
|
|
"method": "GET",
|
|
|
|
"enctype": "application/x-www-form-urlencoded",
|
|
|
|
"params": {
|
|
|
|
"url": "url",
|
|
|
|
"text": "url",
|
|
|
|
"title": "title",
|
2024-03-24 10:50:02 +00:00
|
|
|
},
|
|
|
|
},
|
2023-05-23 19:20:58 +00:00
|
|
|
}
|
|
|
|
self.assertDictEqual(response_body, expected_body)
|
|
|
|
|
|
|
|
@override_settings(LD_CONTEXT_PATH="linkding/")
|
|
|
|
def test_manifest_respects_context_path(self):
|
|
|
|
response = self.client.get("/manifest.json")
|
|
|
|
|
|
|
|
self.assertEqual(response.status_code, 200)
|
|
|
|
|
|
|
|
response_body = response.json()
|
|
|
|
expected_body = {
|
|
|
|
"short_name": "linkding",
|
2024-03-16 14:20:22 +00:00
|
|
|
"name": "linkding",
|
|
|
|
"description": "Self-hosted bookmark service",
|
2023-05-23 19:20:58 +00:00
|
|
|
"start_url": "bookmarks",
|
|
|
|
"display": "standalone",
|
2024-01-27 10:29:16 +00:00
|
|
|
"scope": "/linkding/",
|
2024-03-16 14:20:22 +00:00
|
|
|
"theme_color": "#5856e0",
|
|
|
|
"background_color": "#ffffff",
|
|
|
|
"icons": [
|
|
|
|
{
|
|
|
|
"src": "/linkding/static/logo.svg",
|
|
|
|
"type": "image/svg+xml",
|
|
|
|
"sizes": "512x512",
|
2024-03-24 10:50:02 +00:00
|
|
|
"purpose": "any",
|
2024-03-16 14:20:22 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"src": "/linkding/static/logo-512.png",
|
|
|
|
"type": "image/png",
|
|
|
|
"sizes": "512x512",
|
2024-03-24 10:50:02 +00:00
|
|
|
"purpose": "any",
|
2024-03-16 14:20:22 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"src": "/linkding/static/logo-192.png",
|
|
|
|
"type": "image/png",
|
|
|
|
"sizes": "192x192",
|
2024-03-24 10:50:02 +00:00
|
|
|
"purpose": "any",
|
2024-03-16 14:20:22 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"src": "/linkding/static/maskable-logo.svg",
|
|
|
|
"type": "image/svg+xml",
|
|
|
|
"sizes": "512x512",
|
2024-03-24 10:50:02 +00:00
|
|
|
"purpose": "maskable",
|
2024-03-16 14:20:22 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"src": "/linkding/static/maskable-logo-512.png",
|
|
|
|
"type": "image/png",
|
|
|
|
"sizes": "512x512",
|
2024-03-24 10:50:02 +00:00
|
|
|
"purpose": "maskable",
|
2024-03-16 14:20:22 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"src": "/linkding/static/maskable-logo-192.png",
|
|
|
|
"type": "image/png",
|
|
|
|
"sizes": "192x192",
|
2024-03-24 10:50:02 +00:00
|
|
|
"purpose": "maskable",
|
2024-03-16 14:20:22 +00:00
|
|
|
},
|
|
|
|
],
|
|
|
|
"shortcuts": [
|
|
|
|
{
|
|
|
|
"name": "Add bookmark",
|
|
|
|
"url": "/linkding/bookmarks/new",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "Archived",
|
|
|
|
"url": "/linkding/bookmarks/archived",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "Unread",
|
|
|
|
"url": "/linkding/bookmarks?unread=yes",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "Untagged",
|
|
|
|
"url": "/linkding/bookmarks?q=!untagged",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "Shared",
|
|
|
|
"url": "/linkding/bookmarks/shared",
|
2024-03-24 10:50:02 +00:00
|
|
|
},
|
2024-03-16 14:20:22 +00:00
|
|
|
],
|
|
|
|
"screenshots": [
|
|
|
|
{
|
|
|
|
"src": "/linkding/static/linkding-screenshot.png",
|
|
|
|
"type": "image/png",
|
|
|
|
"sizes": "2158x1160",
|
2024-03-24 10:50:02 +00:00
|
|
|
"form_factor": "wide",
|
2024-03-16 14:20:22 +00:00
|
|
|
}
|
|
|
|
],
|
|
|
|
"share_target": {
|
|
|
|
"action": "/linkding/bookmarks/new",
|
|
|
|
"method": "GET",
|
|
|
|
"enctype": "application/x-www-form-urlencoded",
|
|
|
|
"params": {
|
|
|
|
"url": "url",
|
|
|
|
"text": "url",
|
|
|
|
"title": "title",
|
2024-03-24 10:50:02 +00:00
|
|
|
},
|
|
|
|
},
|
2023-05-23 19:20:58 +00:00
|
|
|
}
|
|
|
|
self.assertDictEqual(response_body, expected_body)
|