style: remove trailing whitespace in mcp_server.py and test_runtime_clarity.py

This commit is contained in:
2026-07-04 14:57:21 -04:00
parent a0e7d3360e
commit 10a29d1bd5
2 changed files with 9 additions and 9 deletions
+3 -3
View File
@@ -2320,7 +2320,7 @@ def gitea_list_profiles() -> dict:
role = _role_kind(p["allowed_operations"], p["forbidden_operations"]) role = _role_kind(p["allowed_operations"], p["forbidden_operations"])
h = REMOTES.get("dadeschools", {}).get("host") # default host h = REMOTES.get("dadeschools", {}).get("host") # default host
username = _authenticated_username(h) if h else None username = _authenticated_username(h) if h else None
prof = { prof = {
"name": p["profile_name"], "name": p["profile_name"],
"role_kind": role, "role_kind": role,
@@ -2344,7 +2344,7 @@ def gitea_list_profiles() -> dict:
for name, p in profiles_dict.items(): for name, p in profiles_dict.items():
role = _role_kind(p.get("allowed_operations", []), p.get("forbidden_operations", [])) role = _role_kind(p.get("allowed_operations", []), p.get("forbidden_operations", []))
is_active = (name == active_name) is_active = (name == active_name)
# Identity status lookup # Identity status lookup
if is_active: if is_active:
h = REMOTES.get("dadeschools", {}).get("host") # default host h = REMOTES.get("dadeschools", {}).get("host") # default host
@@ -2468,7 +2468,7 @@ def gitea_activate_profile(
# 3. Clear identity cache to force a fresh verification # 3. Clear identity cache to force a fresh verification
if h: if h:
_IDENTITY_CACHE.pop(h, None) _IDENTITY_CACHE.pop(h, None)
# 4. Resolve fresh identity # 4. Resolve fresh identity
after_profile = get_profile()["profile_name"] after_profile = get_profile()["profile_name"]
after_identity = _authenticated_username(h) if h else None after_identity = _authenticated_username(h) if h else None
+6 -6
View File
@@ -132,7 +132,7 @@ class TestRuntimeClarity(unittest.TestCase):
res = mcp_server.gitea_list_profiles() res = mcp_server.gitea_list_profiles()
profiles = res["profiles"] profiles = res["profiles"]
self.assertEqual(len(profiles), 2) self.assertEqual(len(profiles), 2)
author_prof = next(p for p in profiles if p["name"] == "author-profile") author_prof = next(p for p in profiles if p["name"] == "author-profile")
self.assertTrue(author_prof["is_active"]) self.assertTrue(author_prof["is_active"])
self.assertEqual(author_prof["role_kind"], "author") self.assertEqual(author_prof["role_kind"], "author")
@@ -153,7 +153,7 @@ class TestRuntimeClarity(unittest.TestCase):
with patch.dict(os.environ, self._env("author-profile", reveal="1"), clear=True): with patch.dict(os.environ, self._env("author-profile", reveal="1"), clear=True):
res = mcp_server.gitea_list_profiles() res = mcp_server.gitea_list_profiles()
profiles = res["profiles"] profiles = res["profiles"]
author_prof = next(p for p in profiles if p["name"] == "author-profile") author_prof = next(p for p in profiles if p["name"] == "author-profile")
self.assertEqual(author_prof["auth"]["name"], "GITEA_TOKEN_AUTHOR") self.assertEqual(author_prof["auth"]["name"], "GITEA_TOKEN_AUTHOR")
self.assertEqual(author_prof["base_url"], "https://gitea.example.com") self.assertEqual(author_prof["base_url"], "https://gitea.example.com")
@@ -173,7 +173,7 @@ class TestRuntimeClarity(unittest.TestCase):
@patch("mcp_server.get_auth_header") @patch("mcp_server.get_auth_header")
def test_activate_profile_succeeds_when_enabled(self, mock_auth, mock_api): def test_activate_profile_succeeds_when_enabled(self, mock_auth, mock_api):
self._write_config(CONFIG_SWITCHING_ENABLED) self._write_config(CONFIG_SWITCHING_ENABLED)
# Setup mock responses for whoami checks # Setup mock responses for whoami checks
mock_auth.side_effect = ["token author-pass", "token reviewer-pass"] mock_auth.side_effect = ["token author-pass", "token reviewer-pass"]
mock_api.side_effect = [{"login": "author-user"}, {"login": "reviewer-user"}] mock_api.side_effect = [{"login": "author-user"}, {"login": "reviewer-user"}]
@@ -181,15 +181,15 @@ class TestRuntimeClarity(unittest.TestCase):
with patch.dict(os.environ, self._env("author-profile"), clear=True): with patch.dict(os.environ, self._env("author-profile"), clear=True):
# Check before state # Check before state
self.assertEqual(gitea_config.selected_profile_name(), "author-profile") self.assertEqual(gitea_config.selected_profile_name(), "author-profile")
res = mcp_server.gitea_activate_profile(profile_name="reviewer-profile") res = mcp_server.gitea_activate_profile(profile_name="reviewer-profile")
self.assertTrue(res["success"]) self.assertTrue(res["success"])
self.assertEqual(res["before_profile"], "author-profile") self.assertEqual(res["before_profile"], "author-profile")
self.assertEqual(res["before_identity"], "author-user") self.assertEqual(res["before_identity"], "author-user")
self.assertEqual(res["after_profile"], "reviewer-profile") self.assertEqual(res["after_profile"], "reviewer-profile")
self.assertEqual(res["after_identity"], "reviewer-user") self.assertEqual(res["after_identity"], "reviewer-user")
# Global variable override should be set # Global variable override should be set
self.assertEqual(gitea_config._active_profile_override, "reviewer-profile") self.assertEqual(gitea_config._active_profile_override, "reviewer-profile")
self.assertEqual(gitea_config.selected_profile_name(), "reviewer-profile") self.assertEqual(gitea_config.selected_profile_name(), "reviewer-profile")