forked from 0xWheatyz/SPARC
Add S3/MinIO storage backend tests for storage.py #1660
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Context
SPARC/storage.pyimplements 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.pycovering:LocalStorage backend:
save(patent_id, data)writes bytes to the expected path under a temp directoryload(patent_id)returns the correct bytes after a priorsaveload(patent_id)raises or returns None for a non-existent IDexists(patent_id)returns True/False correctlyS3Storage backend (using moto or unittest.mock):
save(patent_id, data)callss3.put_objectwith the correct bucket, key, and bodyload(patent_id)callss3.get_objectand returns the response bodyload(patent_id)raises StorageNotFoundError when S3 returns NoSuchKeyAcceptance criteria
pytest tests/ -vmotoor mock)ruff check tests/passes with no errorsPR #1663 has been created for this issue. Work was completed on branch and is ready for review.