From b574650c4aa2d9226a090222b97efa62237d1b39 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 22 Jan 2026 08:00:04 +0000 Subject: [PATCH 1/3] Initial plan From 65de914713738fd98a323e19410985d4f6291730 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 22 Jan 2026 08:03:44 +0000 Subject: [PATCH 2/3] Add tests for ProfileForm __init__ storage field conditional removal Co-authored-by: mhaya <2446046+mhaya@users.noreply.github.com> --- .../weko-user-profiles/tests/test_forms.py | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/modules/weko-user-profiles/tests/test_forms.py b/modules/weko-user-profiles/tests/test_forms.py index 579a5700c0..e83ab515fa 100644 --- a/modules/weko-user-profiles/tests/test_forms.py +++ b/modules/weko-user-profiles/tests/test_forms.py @@ -386,6 +386,48 @@ def test_validate_username(self,app,client,register_form,users,db): res = client.post("/test_form/profile_form",data=data) assert res.data == bytes("invalid","utf-8") + def test_init_storage_fields_removed_when_disabled(self, app): + """Test that storage fields are removed when feature flag is disabled.""" + # Set the config to disable storage modification + app.config.update( + WEKO_RECORDS_UI_USER_STORAGE_MODIFICATION_ENABLED=False + ) + + with app.app_context(): + # Create the form + form = ProfileForm() + + # Verify storage-related fields are removed + assert not hasattr(form, 'access_key'), "access_key field should be removed when feature is disabled" + assert not hasattr(form, 'secret_key'), "secret_key field should be removed when feature is disabled" + assert not hasattr(form, 's3_endpoint_url'), "s3_endpoint_url field should be removed when feature is disabled" + assert not hasattr(form, 's3_region_name'), "s3_region_name field should be removed when feature is disabled" + + # Verify other fields are still present + assert hasattr(form, 'fullname'), "fullname field should still be present" + assert hasattr(form, 'email'), "email field should still be present" + + def test_init_storage_fields_present_when_enabled(self, app): + """Test that storage fields are present when feature flag is enabled.""" + # Set the config to enable storage modification + app.config.update( + WEKO_RECORDS_UI_USER_STORAGE_MODIFICATION_ENABLED=True + ) + + with app.app_context(): + # Create the form + form = ProfileForm() + + # Verify storage-related fields are present + assert hasattr(form, 'access_key'), "access_key field should be present when feature is enabled" + assert hasattr(form, 'secret_key'), "secret_key field should be present when feature is enabled" + assert hasattr(form, 's3_endpoint_url'), "s3_endpoint_url field should be present when feature is enabled" + assert hasattr(form, 's3_region_name'), "s3_region_name field should be present when feature is enabled" + + # Verify other fields are still present + assert hasattr(form, 'fullname'), "fullname field should still be present" + assert hasattr(form, 'email'), "email field should still be present" + # def custom_profile_form_factory(profile_cls): # .tox/c1/bin/pytest --cov=weko_user_profiles tests/test_forms.py::test_custom_profile_form_factory -vv -s --cov-branch --cov-report=term --cov-report=html --basetemp=/code/modules/weko-user-profiles/.tox/c1/tmp class DummyClass: From 4cb7711f07ca633cc6cb0373ea160fa23ece81e0 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 22 Jan 2026 08:05:04 +0000 Subject: [PATCH 3/3] Simplify test assertions and remove verbose error messages Co-authored-by: mhaya <2446046+mhaya@users.noreply.github.com> --- .../weko-user-profiles/tests/test_forms.py | 24 +++++++------------ 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/modules/weko-user-profiles/tests/test_forms.py b/modules/weko-user-profiles/tests/test_forms.py index e83ab515fa..c4f10b920d 100644 --- a/modules/weko-user-profiles/tests/test_forms.py +++ b/modules/weko-user-profiles/tests/test_forms.py @@ -398,14 +398,10 @@ def test_init_storage_fields_removed_when_disabled(self, app): form = ProfileForm() # Verify storage-related fields are removed - assert not hasattr(form, 'access_key'), "access_key field should be removed when feature is disabled" - assert not hasattr(form, 'secret_key'), "secret_key field should be removed when feature is disabled" - assert not hasattr(form, 's3_endpoint_url'), "s3_endpoint_url field should be removed when feature is disabled" - assert not hasattr(form, 's3_region_name'), "s3_region_name field should be removed when feature is disabled" - - # Verify other fields are still present - assert hasattr(form, 'fullname'), "fullname field should still be present" - assert hasattr(form, 'email'), "email field should still be present" + assert not hasattr(form, 'access_key') + assert not hasattr(form, 'secret_key') + assert not hasattr(form, 's3_endpoint_url') + assert not hasattr(form, 's3_region_name') def test_init_storage_fields_present_when_enabled(self, app): """Test that storage fields are present when feature flag is enabled.""" @@ -419,14 +415,10 @@ def test_init_storage_fields_present_when_enabled(self, app): form = ProfileForm() # Verify storage-related fields are present - assert hasattr(form, 'access_key'), "access_key field should be present when feature is enabled" - assert hasattr(form, 'secret_key'), "secret_key field should be present when feature is enabled" - assert hasattr(form, 's3_endpoint_url'), "s3_endpoint_url field should be present when feature is enabled" - assert hasattr(form, 's3_region_name'), "s3_region_name field should be present when feature is enabled" - - # Verify other fields are still present - assert hasattr(form, 'fullname'), "fullname field should still be present" - assert hasattr(form, 'email'), "email field should still be present" + assert hasattr(form, 'access_key') + assert hasattr(form, 'secret_key') + assert hasattr(form, 's3_endpoint_url') + assert hasattr(form, 's3_region_name') # def custom_profile_form_factory(profile_cls): # .tox/c1/bin/pytest --cov=weko_user_profiles tests/test_forms.py::test_custom_profile_form_factory -vv -s --cov-branch --cov-report=term --cov-report=html --basetemp=/code/modules/weko-user-profiles/.tox/c1/tmp