This is an automated email from the ASF dual-hosted git repository.

sbp pushed a commit to branch sbp
in repository https://gitbox.apache.org/repos/asf/tooling-trusted-releases.git


The following commit(s) were added to refs/heads/sbp by this push:
     new ea3c88b  Ensure that the vote test admin user is regarded as an admin
ea3c88b is described below

commit ea3c88bf8a4b5392dfc89837fa2d2c19f3135089
Author: Sean B. Palmer <[email protected]>
AuthorDate: Tue Feb 3 15:40:17 2026 +0000

    Ensure that the vote test admin user is regarded as an admin
---
 tests/unit/test_vote.py | 39 +++++++++++++++++++++++++++++++++------
 1 file changed, 33 insertions(+), 6 deletions(-)

diff --git a/tests/unit/test_vote.py b/tests/unit/test_vote.py
index 170bc49..7d7da0e 100644
--- a/tests/unit/test_vote.py
+++ b/tests/unit/test_vote.py
@@ -17,11 +17,25 @@
 
 """Tests for vote email formatting and binding vote determination."""
 
+import pytest
+from pytest import MonkeyPatch
+
 import atr.storage.writers.vote as vote_writer
 import atr.user as user
 
 
-class _MockCommittee:
+class MockApp:
+    def __init__(self) -> None:
+        self.extensions: dict[str, object] = {}
+
+
+class MockConfig:
+    def __init__(self, allow_tests: bool = False, admin_users_additional: str 
= "") -> None:
+        self.ALLOW_TESTS = allow_tests
+        self.ADMIN_USERS_ADDITIONAL = admin_users_additional
+
+
+class MockCommittee:
     def __init__(
         self,
         name: str = "testproject",
@@ -35,6 +49,13 @@ class _MockCommittee:
         self.committers = committers or []
 
 
[email protected]
+def mock_app(monkeypatch: MonkeyPatch) -> MockApp:
+    app = MockApp()
+    monkeypatch.setattr("asfquart.APP", app)
+    return app
+
+
 def test_binding_vote_body_format() -> None:
     """Binding votes include '(binding)' in the email body."""
     body = vote_writer.format_vote_email_body(
@@ -152,7 +173,7 @@ def test_empty_comment_no_signature() -> None:
 
 def test_pmc_member_has_binding_vote() -> None:
     """PMC members have binding votes."""
-    committee = _MockCommittee(
+    committee = MockCommittee(
         committee_members=["alice", "bob", "charlie"],
         committers=["alice", "bob", "charlie", "dave", "eve"],
     )
@@ -162,7 +183,7 @@ def test_pmc_member_has_binding_vote() -> None:
 
 def test_committer_non_pmc_has_non_binding_vote() -> None:
     """Committers who are not PMC members have non-binding votes."""
-    committee = _MockCommittee(
+    committee = MockCommittee(
         committee_members=["alice", "bob", "charlie"],
         committers=["alice", "bob", "charlie", "dave", "eve"],
     )
@@ -172,7 +193,7 @@ def test_committer_non_pmc_has_non_binding_vote() -> None:
 
 def test_non_committer_has_non_binding_vote() -> None:
     """Non-committers have non-binding votes."""
-    committee = _MockCommittee(
+    committee = MockCommittee(
         committee_members=["alice", "bob", "charlie"],
         committers=["alice", "bob", "charlie", "dave", "eve"],
     )
@@ -186,9 +207,15 @@ def test_none_committee_returns_false() -> None:
     assert is_binding is False
 
 
-def test_admin_not_on_pmc_has_non_binding_vote() -> None:
+def test_admin_not_on_pmc_has_non_binding_vote(mock_app: MockApp, monkeypatch: 
MonkeyPatch) -> None:
     """Admins who are not PMC members do not get binding votes."""
-    committee = _MockCommittee(
+    user._get_additional_admin_users.cache_clear()
+    monkeypatch.setattr("atr.config.get", lambda: MockConfig())
+    mock_app.extensions["admins"] = frozenset({"admin_user"})
+
+    assert user.is_admin("admin_user") is True
+
+    committee = MockCommittee(
         committee_members=["alice", "bob"],
         committers=["alice", "bob", "charlie"],
     )


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to