From 30e83a143c606993e9159b799ce16cbf957a77cf Mon Sep 17 00:00:00 2001 From: David Larlet Date: Tue, 14 Nov 2023 13:37:02 -0500 Subject: [PATCH] Tests download view for permissions --- umap/tests/test_map_views.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/umap/tests/test_map_views.py b/umap/tests/test_map_views.py index 92ff196f..52bd98b3 100644 --- a/umap/tests/test_map_views.py +++ b/umap/tests/test_map_views.py @@ -662,3 +662,24 @@ def test_download(client, map, datalayer): "type": "FeatureCollection", }, ] + + +@pytest.mark.parametrize("share_status", [Map.PRIVATE, Map.BLOCKED]) +def test_download_shared_status_map(client, map, datalayer, share_status): + map.share_status = share_status + map.save() + url = reverse("map_download", args=(map.pk,)) + response = client.get(url) + assert response.status_code == 403 + + +def test_download_my_map(client, map, datalayer): + map.share_status = Map.PRIVATE + map.save() + client.login(username=map.owner.username, password="123123") + url = reverse("map_download", args=(map.pk,)) + response = client.get(url) + assert response.status_code == 200 + # Test response is a json + j = json.loads(response.content.decode()) + assert j["type"] == "umap"