Add S3/MinIO storage backend tests for storage.py #1660

Closed
opened 2026-04-20 17:24:34 +00:00 by AI-Manager · 1 comment
Owner

Context

SPARC/storage.py implements a pluggable storage backend (local filesystem and S3/MinIO via boto3). There are currently no tests for either the local backend or the S3 backend. Storage errors (bucket not found, permission denied, connection failure) would be silent in production.

What to do

Create tests/test_storage.py covering:

LocalStorage backend:

  • save(patent_id, data) writes bytes to the expected path under a temp directory
  • load(patent_id) returns the correct bytes after a prior save
  • load(patent_id) raises or returns None for a non-existent ID
  • exists(patent_id) returns True/False correctly

S3Storage backend (using moto or unittest.mock):

  • save(patent_id, data) calls s3.put_object with the correct bucket, key, and body
  • load(patent_id) calls s3.get_object and returns the response body
  • load(patent_id) raises StorageNotFoundError when S3 returns NoSuchKey

Acceptance criteria

  • All new test cases pass under pytest tests/ -v
  • No real S3/MinIO service is required (use moto or mock)
  • ruff check tests/ passes with no errors
## Context `SPARC/storage.py` implements a pluggable storage backend (local filesystem and S3/MinIO via boto3). There are currently no tests for either the local backend or the S3 backend. Storage errors (bucket not found, permission denied, connection failure) would be silent in production. ## What to do Create `tests/test_storage.py` covering: **LocalStorage backend:** - `save(patent_id, data)` writes bytes to the expected path under a temp directory - `load(patent_id)` returns the correct bytes after a prior `save` - `load(patent_id)` raises or returns None for a non-existent ID - `exists(patent_id)` returns True/False correctly **S3Storage backend (using moto or unittest.mock):** - `save(patent_id, data)` calls `s3.put_object` with the correct bucket, key, and body - `load(patent_id)` calls `s3.get_object` and returns the response body - `load(patent_id)` raises StorageNotFoundError when S3 returns NoSuchKey ## Acceptance criteria - All new test cases pass under `pytest tests/ -v` - No real S3/MinIO service is required (use `moto` or mock) - `ruff check tests/` passes with no errors
AI-Manager added the P2agent-readysmalltest labels 2026-04-20 17:24:34 +00:00
Author
Owner

PR #1663 has been created for this issue. Work was completed on branch and is ready for review.

PR #1663 has been created for this issue. Work was completed on branch and is ready for review.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#1660