From 13ca7e3e5da7033147d568c429bfdc905f01db44 Mon Sep 17 00:00:00 2001 From: David Larlet Date: Wed, 15 Nov 2023 14:13:33 -0500 Subject: [PATCH] Add tests for favicon-related views --- umap/tests/test_views.py | 26 ++++++++++++++++++++++++++ umap/views.py | 2 +- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/umap/tests/test_views.py b/umap/tests/test_views.py index 08c4586b..1fced968 100644 --- a/umap/tests/test_views.py +++ b/umap/tests/test_views.py @@ -364,3 +364,29 @@ def test_user_profile_does_not_allow_to_edit_other_fields(client, map): user = User.objects.get(pk=map.owner.pk) assert user.email != new_email assert user.is_superuser is False + + +def test_favicon_redirection(client): + response = client.get("/favicon.ico") + assert response.status_code == 302 + assert response.url == "/static/umap/favicons/favicon.ico" + + +def test_webmanifest(client): + response = client.get("/manifest.webmanifest") + assert response.status_code == 200 + assert response["content-type"] == "application/json" + assert response.json() == { + "icons": [ + { + "sizes": "192x192", + "src": "/static/umap/favicons/icon-192.png", + "type": "image/png", + }, + { + "sizes": "512x512", + "src": "/static/umap/favicons/icon-512.png", + "type": "image/png", + }, + ] + } diff --git a/umap/views.py b/umap/views.py index 6ac0d6a3..824baf4e 100644 --- a/umap/views.py +++ b/umap/views.py @@ -422,7 +422,7 @@ def _urls_for_js(urls=None): def simple_json_response(**kwargs): - return HttpResponse(json.dumps(kwargs)) + return HttpResponse(json.dumps(kwargs), content_type="application/json") # ############## #