From 2ffa7e5f23188061afc1fdc5c93ef5d4491c00b2 Mon Sep 17 00:00:00 2001 From: chas Date: Fri, 21 Jul 2023 19:13:27 +0100 Subject: [PATCH] fix: flip the dataset resource logic around in the tests --- ckanext/validation/tests/test_logic.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/ckanext/validation/tests/test_logic.py b/ckanext/validation/tests/test_logic.py index e2bf3a5e..9c55ed76 100644 --- a/ckanext/validation/tests/test_logic.py +++ b/ckanext/validation/tests/test_logic.py @@ -347,8 +347,9 @@ def test_run_non_auth_user(self): user = factories.User() org = factories.Organization() dataset = factories.Dataset( - owner_org=org["id"], resources=[factories.Resource()] + owner_org=org["id"] ) + resource = factories.Resource(package_id=dataset['id']) context = {"user": user["name"], "model": model} @@ -357,7 +358,7 @@ def test_run_non_auth_user(self): call_auth, "resource_validation_run", context=context, - resource_id=dataset["resources"][0]["id"], + resource_id=resource["id"], ) def test_run_auth_user(self): @@ -367,8 +368,9 @@ def test_run_auth_user(self): users=[{"name": user["name"], "capacity": "editor"}] ) dataset = factories.Dataset( - owner_org=org["id"], resources=[factories.Resource()] + owner_org=org["id"] ) + resource = factories.Resource(package_id=dataset['id']) context = {"user": user["name"], "model": model} @@ -376,7 +378,7 @@ def test_run_auth_user(self): call_auth( "resource_validation_run", context=context, - resource_id=dataset["resources"][0]["id"], + resource_id=resource["id"], ) is True ) @@ -416,8 +418,9 @@ def test_delete_non_auth_user(self): user = factories.User() org = factories.Organization() dataset = factories.Dataset( - owner_org=org["id"], resources=[factories.Resource()] + owner_org=org["id"] ) + resource = factories.Resource(package_id=dataset['id']) context = {"user": user["name"], "model": model} @@ -426,7 +429,7 @@ def test_delete_non_auth_user(self): call_auth, "resource_validation_delete", context=context, - resource_id=dataset["resources"][0]["id"], + resource_id=resource["id"], ) def test_delete_auth_user(self): @@ -436,8 +439,9 @@ def test_delete_auth_user(self): users=[{"name": user["name"], "capacity": "editor"}] ) dataset = factories.Dataset( - owner_org=org["id"], resources=[factories.Resource()] + owner_org=org["id"] ) + resource = factories.Resource(package_id=dataset['id']) context = {"user": user["name"], "model": model} @@ -445,7 +449,7 @@ def test_delete_auth_user(self): call_auth( "resource_validation_delete", context=context, - resource_id=dataset["resources"][0]["id"], + resource_id=resource["id"], ) is True )