Metadata
Origin
Review of PR #264
What to build
Two test-infrastructure improvements that remove direct private-attr access from the webhook test suite (and adjacent tests):
-
Public secrets setter on ContextDependency. The github_app_enabled fixture in tests/handlers/webhooks_github_test.py (lines 52-80) currently saves and pokes _github_app_id, _github_app_private_key, and _github_webhook_secret directly on the context_dependency singleton. Add a public method (e.g. set_github_secrets(app_id, private_key, webhook_secret)) on ContextDependency and have the fixture use it.
Out of scope for this issue: tests/conftest.py:119-125 also pokes _superadmin_usernames and _user_info_store directly. That is a parallel piece of test-infrastructure hygiene; flag it for a separate follow-up rather than expanding scope here.
-
tests/support/arq_testing.py helper. Tests currently access arq_dependency._arq_queue and arq_queue._job_metadata directly to count dashboard_sync jobs. Centralize via a helper so private-API access lives in one place.
Known direct-access sites to migrate:
tests/handlers/webhooks_github_test.py:42-49 (_count_dashboard_sync_jobs).
tests/storage/queue_backend_test.py:29-36.
tests/worker/build_processing_test.py:468-472.
Approach sketch
ContextDependency.set_github_secrets(app_id: int | None, private_key: SecretStr | None, webhook_secret: SecretStr | None) -> None — synchronous, scoped to the three GitHub-App fields. The existing async initialize is broader and not appropriate for narrow test fixture use. Document intent in the docstring.
- New file
tests/support/arq_testing.py exporting:
count_jobs_by_name(arq_queue: MockArqQueue, name: str, queue_name: str | None = None) -> int
get_jobs_by_name(arq_queue: MockArqQueue, name: str, queue_name: str | None = None) -> list[JobMetadata] (if useful for debug assertions)
- Migrate the three known call sites in this issue.
Acceptance criteria
Metadata
tickets/DM-54689-github-webhookOrigin
Review of PR #264
What to build
Two test-infrastructure improvements that remove direct private-attr access from the webhook test suite (and adjacent tests):
Public secrets setter on
ContextDependency. Thegithub_app_enabledfixture intests/handlers/webhooks_github_test.py(lines 52-80) currently saves and pokes_github_app_id,_github_app_private_key, and_github_webhook_secretdirectly on thecontext_dependencysingleton. Add a public method (e.g.set_github_secrets(app_id, private_key, webhook_secret)) onContextDependencyand have the fixture use it.Out of scope for this issue:
tests/conftest.py:119-125also pokes_superadmin_usernamesand_user_info_storedirectly. That is a parallel piece of test-infrastructure hygiene; flag it for a separate follow-up rather than expanding scope here.tests/support/arq_testing.pyhelper. Tests currently accessarq_dependency._arq_queueandarq_queue._job_metadatadirectly to countdashboard_syncjobs. Centralize via a helper so private-API access lives in one place.Known direct-access sites to migrate:
tests/handlers/webhooks_github_test.py:42-49(_count_dashboard_sync_jobs).tests/storage/queue_backend_test.py:29-36.tests/worker/build_processing_test.py:468-472.Approach sketch
ContextDependency.set_github_secrets(app_id: int | None, private_key: SecretStr | None, webhook_secret: SecretStr | None) -> None— synchronous, scoped to the three GitHub-App fields. The existing asyncinitializeis broader and not appropriate for narrow test fixture use. Document intent in the docstring.tests/support/arq_testing.pyexporting:count_jobs_by_name(arq_queue: MockArqQueue, name: str, queue_name: str | None = None) -> intget_jobs_by_name(arq_queue: MockArqQueue, name: str, queue_name: str | None = None) -> list[JobMetadata](if useful for debug assertions)Acceptance criteria
ContextDependency.set_github_secrets(...)exists and is documented.github_app_enabledfixture usesset_github_secretsrather than direct private-attr assignment for the three GitHub App secrets.tests/support/arq_testing.pyexists and exportscount_jobs_by_name(plusget_jobs_by_nameif added).grep -R "_job_metadata" tests/returns matches only insidetests/support/arq_testing.py.TC_HOST=localhost TESTCONTAINERS_RYUK_DISABLED=true uv run --only-group=nox nox -s test).