Repository navigation
Extra links: drop the redundant check for a user without a group, and restore the setting in the tests - #1808
Merged
Merged
Conversation
Coverage Report for CI Build 44411325200Coverage remained the same at 91.644%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
… restore the setting in the tests extra_links() skipped a link with authorized_groups for a user without a group, then for a user with no group in authorized_groups. The first check is redundant: for a user without a group, the intersection is empty, and the second check skips the link. It is removed. The behaviour does not change. BaseViewsTestCase and NginxAuthRequestViewTestCase set the extra_links setting and did not restore it. The removed check was covered only when a later test, in the same process, rendered a console page for a user without a group. With --parallel auto, the test classes go to different processes from run to run, and Coveralls reported a coverage regression on unrelated pull requests. Both classes now restore the setting with enterClassContext(patch.dict(...)). The extra links assertions are in one helper, _assert_extra_links(). It compares the expected links with the zentral_extra_links context, counts the rendered extra links, and checks the anchor text and the URL of each test link in the page. New tests: a user without a group gets only the links without authorized_groups, and a superuser without a group gets all the links. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
np5
force-pushed
the
tests-extra-links-no-group
branch
from
November 18, 2026 22:24
1284c1e to
1a6a5ea
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
extra_links()inzentral/conf/context_processors.pyhad two checks for a link withauthorized_groupsand a user that is not a superuser:authorized_groupshave no common name, skip the link.The first check is redundant: for a user without a group, the intersection is empty, and the second check skips the link. No test targeted the first check.
Two test classes set
settings._collection["extra_links"]insetUpTestDataand did not restore it:BaseViewsTestCaseintests/server_base/test_index.pyNginxAuthRequestViewTestCaseintests/server_accounts/test_nginx_auth_request_view.pyThe first check was covered only when a later test, in the same process, rendered a console page for a user without a group. Since the suite runs with
--parallel auto, the test classes go to different processes from run to run. Coveralls then reported this line as a coverage regression on unrelated pull requests, for example #1804.Change
extra_linkssetting after each of the two test classes withenterClassContext(patch.dict(...)). When only one class restores the setting, it can restore the links that the other class left._assert_extra_links(). The helper:zentral_extra_linkscontext,test_index_user_without_group_extra_links: a user without a group gets only the links withoutauthorized_groups.test_index_superuser_without_group_all_extra_links: a superuser without a group gets all the links.No CHANGELOG entry: the behaviour does not change.
Checks
tests_with_coverageon a fresh stack: OK.BaseViewsTestCasecover all the lines ofextra_links(), whatever the order of the test classes.🤖 Generated with Claude Code