Skip to content

Commit

Permalink
Add model to context in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
amercader committed May 22, 2024
1 parent 92fd314 commit e56cc05
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions ckanext/embeddings/tests/test_auth.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import pytest

from ckan import model
from ckan.plugins import toolkit
from ckan.tests import factories, helpers

Expand All @@ -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"])


Expand All @@ -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"])

0 comments on commit e56cc05

Please sign in to comment.