Skip to content

test : added unit tests for _gather_scan_summary in notification_service - #2428

Open
tmdeveloper007 wants to merge 1 commit into
utksh1:mainfrom
tmdeveloper007:#2423
Open

test : added unit tests for _gather_scan_summary in notification_service#2428
tmdeveloper007 wants to merge 1 commit into
utksh1:mainfrom
tmdeveloper007:#2423

Conversation

@tmdeveloper007

Copy link
Copy Markdown
Contributor

Closes #2423.

Summary of What Has Been Done:
Created a new test file testing/backend/unit/test_notification_service_gather_scan_summary.py with 8 unit tests for the _gather_scan_summary() async helper in backend/secuscan/notification_service.py.

The function is exercised indirectly through process_scan_completion_webhook but not directly tested.

Changes Made:

  • New file: testing/backend/unit/test_notification_service_gather_scan_summary.py
  • Inline setup_test_environment fixture (to avoid loading FastAPI-dependent conftest)
  • Inline _seed_task_with_findings helper for test data setup
  • Added 8 tests covering:
    • Returns None for nonexistent task_id
    • Returns correct dict structure with all expected keys
    • Severity counts correctly aggregated (2 critical, 1 high, 1 low)
    • Zero findings gives total_findings=0 and empty counts
    • error_message from task included in summary
    • report_link contains the task_id
    • status is lowercased
    • tool_name uses the database value

Impact it Made:

  • Directly validates the summary aggregation logic independent of webhook delivery
  • Ensures severity counts are computed correctly
  • Provides clear unit-level coverage for the helper

Note: This task is being handled by tmdeveloper007 — please assign to that account when picking it up.

@utksh1 utksh1 added area:backend Backend API, database, or service work level:beginner 20 pts difficulty label for small beginner-friendly PRs type:testing Testing work category bonus label labels Aug 4, 2026

@utksh1 utksh1 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code change is reviewed and the backend/lint checks are green. Merge remains blocked by the required frontend audit, which reports the pre-existing high-severity undici vulnerability; I am not bypassing that security gate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:backend Backend API, database, or service work level:beginner 20 pts difficulty label for small beginner-friendly PRs type:testing Testing work category bonus label

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test : add unit tests for _gather_scan_summary in notification_service

2 participants