File tree Expand file tree Collapse file tree 2 files changed +59
-0
lines changed
Expand file tree Collapse file tree 2 files changed +59
-0
lines changed Original file line number Diff line number Diff line change 1+ """Minimal boto3 stub for local testing without the real dependency."""
2+
3+ from __future__ import annotations
4+
5+ from .session import Session
6+ from . import session as session # re-export module for compatibility
7+
8+ __all__ = ["client" , "resource" , "session" , "Session" ]
9+
10+ _default_session : Session | None = None
11+
12+
13+ def _get_default_session () -> Session :
14+ global _default_session
15+ if _default_session is None :
16+ _default_session = Session ()
17+ return _default_session
18+
19+
20+ def client (* args , ** kwargs ): # pragma: no cover - simple pass-through
21+ return _get_default_session ().client (* args , ** kwargs )
22+
23+
24+ def resource (* _args , ** _kwargs ): # pragma: no cover - currently unused
25+ raise NotImplementedError ("boto3.resource stub is not implemented" )
Original file line number Diff line number Diff line change 1+ """Minimal subset of boto3.session.Session used in tests."""
2+
3+ from __future__ import annotations
4+
5+ from types import SimpleNamespace
6+
7+
8+ class _StubBody :
9+ def read (self ) -> bytes : # pragma: no cover - trivial
10+ return b""
11+
12+
13+ class _StubS3Client :
14+ def __init__ (self ) -> None :
15+ self .exceptions = SimpleNamespace (NoSuchKey = Exception )
16+
17+ def upload_file (self , * _args , ** _kwargs ): # pragma: no cover - trivial
18+ return None
19+
20+ def get_object (self , ** _kwargs ): # pragma: no cover - trivial
21+ return {"Body" : _StubBody ()}
22+
23+ def head_object (self , ** _kwargs ): # pragma: no cover - trivial
24+ return {"ContentLength" : 0 }
25+
26+
27+ class Session : # pragma: no cover - compatibility shim
28+ def __init__ (self , ** _kwargs ) -> None :
29+ return
30+
31+ def client (self , service_name : str , ** _kwargs ):
32+ if service_name .lower () != "s3" :
33+ raise NotImplementedError ("Stub supports only S3 client" )
34+ return _StubS3Client ()
You can’t perform that action at this time.
0 commit comments