Summary of What Needs to be Done:
Add unit tests for the _gather_scan_summary() async helper function in backend/secuscan/notification_service.py. This function collects task status, severity counts, and a report link for a scan completion webhook. It queries the database for task and finding records.
The existing test file testing/backend/unit/test_notification_service.py has 36 tests that cover process_scan_completion_webhook and other delivery functions, but _gather_scan_summary is not directly imported or tested — it is only exercised indirectly through process_scan_completion_webhook.
Changes that Need to be Made:
Add a new test section (or new test class) in testing/backend/unit/test_notification_service.py:
- Import
_gather_scan_summary from backend.secuscan.notification_service
- Test that it returns None when the task_id does not exist in the database
- Test that it returns a summary dict with correct structure when the task exists
- Test that severity_counts correctly aggregates findings by severity
- Test that the report_link includes the task_id and uses the configured base_url
- Test that
error_message from the task record is included in the summary
- Test that
tool_name falls back to plugin_id when tool_name is not set
- Use the existing
test_db fixture (AsyncDatabase) to set up test data
Impact that it would Provide:
- Directly validates the summary aggregation logic independent of webhook delivery
- Ensures severity counts are computed correctly regardless of webhook configuration
- Provides clear unit-level coverage for the helper before it is used in more complex flows
Note: This task is being handled by tmdeveloper007 — please assign to that account when picking it up.
Summary of What Needs to be Done:
Add unit tests for the
_gather_scan_summary()async helper function inbackend/secuscan/notification_service.py. This function collects task status, severity counts, and a report link for a scan completion webhook. It queries the database for task and finding records.The existing test file
testing/backend/unit/test_notification_service.pyhas 36 tests that coverprocess_scan_completion_webhookand other delivery functions, but_gather_scan_summaryis not directly imported or tested — it is only exercised indirectly throughprocess_scan_completion_webhook.Changes that Need to be Made:
Add a new test section (or new test class) in
testing/backend/unit/test_notification_service.py:_gather_scan_summaryfrombackend.secuscan.notification_serviceerror_messagefrom the task record is included in the summarytool_namefalls back toplugin_idwhentool_nameis not settest_dbfixture (AsyncDatabase) to set up test dataImpact that it would Provide:
Note: This task is being handled by tmdeveloper007 — please assign to that account when picking it up.