From 79cac740b7b02891b3cd5926b3d2018d13841fa3 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 8 Dec 2025 16:01:13 +0000 Subject: [PATCH 1/4] Initial plan From 62909a7d7efce04002a28ffe20b00bf16663e9b8 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 8 Dec 2025 16:04:47 +0000 Subject: [PATCH 2/4] Fix mock imports and flake8 violations - Replace 'import mock' with 'from unittest import mock' in test files - Fix isinstance() check in test_actions.py - Remove extra blank lines in test_validators.py - Fix indentation in setup.py Co-authored-by: ChasNelson1990 <7795189+ChasNelson1990@users.noreply.github.com> --- ckanext/fork/tests/test_actions.py | 2 +- ckanext/fork/tests/test_helpers.py | 2 +- ckanext/fork/tests/test_validators.py | 6 +----- setup.py | 2 +- 4 files changed, 4 insertions(+), 8 deletions(-) diff --git a/ckanext/fork/tests/test_actions.py b/ckanext/fork/tests/test_actions.py index 4358f66..d5c2ae5 100644 --- a/ckanext/fork/tests/test_actions.py +++ b/ckanext/fork/tests/test_actions.py @@ -68,7 +68,7 @@ def test_resource_autocomplete(self, q, result_names, datasets): def test_resource_autocomplete_output_format(self, datasets): result = call_action('resource_autocomplete', q="Test Resource 08") - assert type(result) == list + assert isinstance(result, list) for dataset in result: assert set(dataset.keys()) == { diff --git a/ckanext/fork/tests/test_helpers.py b/ckanext/fork/tests/test_helpers.py index 8a91019..eac78a8 100644 --- a/ckanext/fork/tests/test_helpers.py +++ b/ckanext/fork/tests/test_helpers.py @@ -2,7 +2,7 @@ from ckan.tests import factories from ckanext.fork import helpers from ckan.plugins import toolkit -import mock +from unittest import mock @pytest.mark.usefixtures('clean_db', 'with_request_context') diff --git a/ckanext/fork/tests/test_validators.py b/ckanext/fork/tests/test_validators.py index 218fecf..b7f4848 100644 --- a/ckanext/fork/tests/test_validators.py +++ b/ckanext/fork/tests/test_validators.py @@ -3,7 +3,7 @@ import ckanext.fork.validators as fork_validators import ckan.plugins.toolkit as toolkit from ckan.tests import factories -import mock +from unittest import mock @pytest.mark.usefixtures('clean_db') @@ -62,7 +62,6 @@ def test_valid_activity_id(self, value, result): with result: fork_validators.valid_activity_id(key, flattened_data, {}, {'user': user['name']}) - @pytest.mark.parametrize("fork_key, fork_value, result", [ (('resources', 0, 'fork_resource'), "resource-id", does_not_raise()), (('resources', 0, 'fork_resource'), "", pytest.raises(toolkit.Invalid)), @@ -83,7 +82,6 @@ def test_check_forked_object(self, fork_key, fork_value, result): with result: fork_validators.check_forked_object(key, flattened_data, {}, {'user': 'user'}) - @pytest.mark.parametrize("new_value, result", [ ("different-value", pytest.raises(toolkit.Invalid)), ("original-value", does_not_raise()), @@ -102,5 +100,3 @@ def test_dataset_field_not_changed(self, new_value, result): {}, {'user': 'user', 'package': dataset} ) - - diff --git a/setup.py b/setup.py index 8784d07..19b949c 100644 --- a/setup.py +++ b/setup.py @@ -55,7 +55,7 @@ # You can just specify the packages manually here if your project is # simple. Or you can use find_packages(). packages=find_packages(exclude=['contrib', 'docs', 'tests*']), - namespace_packages=['ckanext'], + namespace_packages=['ckanext'], install_requires=[ # CKAN extensions should not list dependencies here, but in a separate From 85d8a0d77ddde4618f9a96a9232f9d4ae89c5b52 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 8 Dec 2025 16:22:39 +0000 Subject: [PATCH 3/4] Fix test_valid_activity_id resource creation order - Create dataset before resource to avoid duplicate ID error - Pass package_id when creating resource (following conftest.py pattern) Co-authored-by: ChasNelson1990 <7795189+ChasNelson1990@users.noreply.github.com> --- ckanext/fork/tests/test_validators.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ckanext/fork/tests/test_validators.py b/ckanext/fork/tests/test_validators.py index b7f4848..0abb8e2 100644 --- a/ckanext/fork/tests/test_validators.py +++ b/ckanext/fork/tests/test_validators.py @@ -45,8 +45,8 @@ def test_valid_resource_id(self, value, result): @pytest.mark.parametrize("value, result", VALID_ID_PARAMS) def test_valid_activity_id(self, value, result): user = factories.User() - resource = factories.Resource() - dataset = factories.Dataset(resources=[resource]) + dataset = factories.Dataset() + resource = factories.Resource(package_id=dataset['id']) activity = factories.Activity( activity_type="changed package", object_id=dataset["id"], From 38b97250ef5f0258bfdc7af648d2366ad65b33a2 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 8 Dec 2025 19:40:25 +0000 Subject: [PATCH 4/4] Remove unused resource variable in test_valid_activity_id Fixes flake8 lint error for unused variable Co-authored-by: ChasNelson1990 <7795189+ChasNelson1990@users.noreply.github.com> --- ckanext/fork/tests/test_validators.py | 1 - 1 file changed, 1 deletion(-) diff --git a/ckanext/fork/tests/test_validators.py b/ckanext/fork/tests/test_validators.py index 0abb8e2..a8bb763 100644 --- a/ckanext/fork/tests/test_validators.py +++ b/ckanext/fork/tests/test_validators.py @@ -46,7 +46,6 @@ def test_valid_resource_id(self, value, result): def test_valid_activity_id(self, value, result): user = factories.User() dataset = factories.Dataset() - resource = factories.Resource(package_id=dataset['id']) activity = factories.Activity( activity_type="changed package", object_id=dataset["id"],