Skip to content

test : added unit tests for cache module-level functions#1266

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

test : added unit tests for cache module-level functions#1266
tmdeveloper007 wants to merge 1 commit into
utksh1:mainfrom
tmdeveloper007:#1261

Conversation

@tmdeveloper007

Copy link
Copy Markdown
Contributor

Closes #1261.

Summary of What Has Been Done:
Added a new test file testing/backend/unit/test_cache_module.py covering the four module-level functions in cache.py that were not tested in the existing test_cache_helpers.py (which focuses on CacheClient).

Changes Made:

  • New file: testing/backend/unit/test_cache_module.py
  • TestInitCache: 3 test cases — returns CacheClient, sets global, replaces existing global
  • TestGetCache: 2 test cases — returns initialised cache, raises RuntimeError when not initialised
  • TestInvalidateViewCache: 2 test cases — no-op when cache is None, calls delete_prefix for each expected prefix
  • TestInvalidatePluginCaches: 2 test cases — no-op when cache is None, calls delete_prefix for summary: and plugins: prefixes
  • ASCII only, no unicode, trailing newline at end of file

Impact it Made:

  • These module-level functions are called by route handlers after every write (findings, reports, plugins). Incorrect prefixes cause stale cache to persist and corrupt API responses.
  • No existing tests covered these functions.

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

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test : add unit tests for cache module-level functions

1 participant