From e56cc0573dbaa11aa51bfacc203e7a08cdf14e35 Mon Sep 17 00:00:00 2001 From: amercader Date: Wed, 22 May 2024 10:01:01 +0200 Subject: [PATCH] Add model to context in tests --- ckanext/embeddings/tests/test_auth.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/ckanext/embeddings/tests/test_auth.py b/ckanext/embeddings/tests/test_auth.py index d4e6bb5..ca05b44 100644 --- a/ckanext/embeddings/tests/test_auth.py +++ b/ckanext/embeddings/tests/test_auth.py @@ -1,5 +1,6 @@ import pytest +from ckan import model from ckan.plugins import toolkit from ckan.tests import factories, helpers @@ -9,11 +10,11 @@ def test_package_similar_show_auth_public_dataset(): dataset = factories.Dataset() - context = {"user": ""} + context = {"user": "", "model": model} assert helpers.call_auth("package_similar_show", context, id=dataset["id"]) user = factories.User() - context = {"user": user["name"]} + context = {"user": user["name"], "model": model} assert helpers.call_auth("package_similar_show", context, id=dataset["id"]) @@ -23,13 +24,13 @@ def test_package_similar_show_auth_private_dataset(): user2 = factories.User() org = factories.Organization(users=[{"name": user1["name"], "capacity": "member"}]) dataset = factories.Dataset(private=True, owner_org=org["id"]) - context = {"user": ""} + context = {"user": "", "model": model} with pytest.raises(toolkit.NotAuthorized): helpers.call_auth("package_similar_show", context, id=dataset["id"]) - context = {"user": user2["name"]} + context = {"user": user2["name"], "model": model} with pytest.raises(toolkit.NotAuthorized): helpers.call_auth("package_similar_show", context, id=dataset["id"]) - context = {"user": user1["name"]} + context = {"user": user1["name"], "model": model} assert helpers.call_auth("package_similar_show", context, id=dataset["id"])