Skip to content

test : add unit tests for Database helper methods #1726

Description

@tmdeveloper007

Summary of What Needs to be Done:
backend/secuscan/database.py contains the Database class with several helper methods that are not covered by existing test files (test_database_connection.py covers init/path only, test_database_workflow_versions.py covers workflow version methods). The uncovered Database class methods include:

  • execute: runs a query and returns lastrowid
  • fetchone: fetches a single row
  • fetchall: fetches all rows
  • fetchval: fetches a single scalar value
  • fetch_page: fetches paginated results

Changes that Need to be Made:
Create testing/backend/unit/test_database.py covering:

  • Database.execute returns lastrowid after INSERT
  • Database.execute returns None after non-INSERT queries
  • Database.fetchone returns row dict for existing record
  • Database.fetchone returns None for missing record
  • Database.fetchall returns list of row dicts
  • Database.fetchall returns empty list when no rows
  • Database.fetchval returns scalar value
  • Database.fetchval returns default when no rows
  • Database.fetch_page applies limit and offset
  • All methods are safe against None/empty inputs

Impact that it would Provide:

  • Coverage: fills the gap in Database class testing (only connection tests exist)
  • Reliability: prevents regressions in core data access methods
  • Integration safety: these methods are used throughout the codebase

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions