Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions modules/weko-user-profiles/tests/test_forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,40 @@ 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')
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."""
# 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')
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
class DummyClass:
Expand Down
Loading