Skip to content

Commit 81d9f18

Browse files
committed
fix(test): mock github-app-private-key in _build_app_with_app_config
The _get_app_installation_token function reads the private key from secrets.get('github-app-private-key'), but the test helper _build_app_with_app_config only mocked secrets.get for github_token. This caused test_repo_endpoint_still_uses_app_token to return 401 instead of 200. Replace the generic AsyncMock with a side_effect that returns the private key for 'github-app-private-key' and the PAT for 'github_token'.
1 parent f122a53 commit 81d9f18

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

‎tests/test_routes_github.py‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -341,12 +341,17 @@ def _build_app_with_app_config(
341341
app = FastAPI()
342342
app.include_router(github_router)
343343

344-
# SecretsStore (PAT)
344+
# SecretsStore (PAT + App private key)
345345
mock_secrets = MagicMock()
346-
if token:
347-
mock_secrets.get = AsyncMock(return_value={"value": token})
348-
else:
349-
mock_secrets.get = AsyncMock(return_value=None)
346+
347+
async def _secrets_get(key: str):
348+
if key == "github_token":
349+
return {"value": token} if token else None
350+
if key == "github-app-private-key":
351+
return {"value": "fake-private-key"}
352+
return None
353+
354+
mock_secrets.get = AsyncMock(side_effect=_secrets_get)
350355
app.state.secrets = mock_secrets
351356

352357
# App config

0 commit comments

Comments
 (0)