Skip to content

Conversation

Copy link

Copilot AI commented Jan 22, 2026

The get_query and get_count_query methods in LocationModelView filter locations based on user roles but lacked test coverage.

Changes

  • Added test_get_query: Verifies that system administrators see all locations (including default) while non-system users see only non-default locations
  • Added test_get_count_query: Verifies count queries apply the same role-based filters
  • Test coverage: 4 scenarios per method covering system admin, repository admin, community admin, and no-role users
  • Database cleanup: Added try/finally blocks to prevent test data contamination

Example

# System Administrator sees all locations
mock_user.roles = [MagicMock(name='System Administrator')]
with patch('invenio_files_rest.admin.current_user', mock_user):
    view = LocationModelView(Location, db.session)
    locations = view.get_query().all()
    # Returns both default and non-default locations

# Repository Administrator filtered
mock_user.roles = [MagicMock(name='Repository Administrator')]
with patch('invenio_files_rest.admin.current_user', mock_user):
    locations = view.get_query().all()
    # Returns only non-default locations (default=False)

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 3 commits January 22, 2026 08:08
Co-authored-by: mhaya <2446046+mhaya@users.noreply.github.com>
Co-authored-by: mhaya <2446046+mhaya@users.noreply.github.com>
Co-authored-by: mhaya <2446046+mhaya@users.noreply.github.com>
Copy link
Author

Copilot AI commented Jan 22, 2026

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • docker-auth.elastic.co
    • Triggering command: /usr/libexec/docker/cli-plugins/docker-buildx /usr/libexec/docker/cli-plugins/docker-buildx bake --file - --progress rawjson --metadata-file /tmp/compose-build-metadataFile-1352878921.json --allow fs.read=/home/REDACTED/work/weko/weko/inbox --allow fs.read=/home/REDACTED/work/weko/weko --allow fs.read=/home/REDACTED/work/weko/weko --allow fs.read=/home/REDACTED/work/weko/weko --allow fs.read=/home/REDACTED/work/weko/weko/nginx (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title [WIP] WIP Address feedback on disabling storage function implementation Add test coverage for role-based location filtering in LocationModelView Jan 22, 2026
Copilot AI requested a review from mhaya January 22, 2026 08:14
@mhaya mhaya marked this pull request as ready for review January 22, 2026 08:31
@mhaya mhaya merged commit 9e24598 into fix/issue57294 Jan 22, 2026
16 of 90 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants