test: add scenario eval runner, recorded fixtures, and baseline comparison
This commit is contained in:
parent
3dc1af5f0c
commit
0664cc2d27
38 changed files with 6986 additions and 5 deletions
30
eval/recording/model.py
Normal file
30
eval/recording/model.py
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
"""Transport-neutral cassette interaction model."""
|
||||
|
||||
import base64
|
||||
from dataclasses import dataclass
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class RecordedInteraction:
|
||||
"""One completed HTTP exchange with exact response chunks."""
|
||||
|
||||
method: str
|
||||
url: str
|
||||
status: int
|
||||
request_body: bytes
|
||||
response_chunks: tuple[bytes, ...]
|
||||
|
||||
def as_dict(self) -> dict[str, object]:
|
||||
"""Encode byte fields losslessly for JSON storage."""
|
||||
return {
|
||||
"method": self.method,
|
||||
"url": self.url,
|
||||
"status": self.status,
|
||||
"request_body_base64": _encode(self.request_body),
|
||||
"response_body_base64": _encode(b"".join(self.response_chunks)),
|
||||
"response_chunks_base64": [_encode(chunk) for chunk in self.response_chunks],
|
||||
}
|
||||
|
||||
|
||||
def _encode(value: bytes) -> str:
|
||||
return base64.b64encode(value).decode("ascii")
|
||||
Loading…
Add table
Add a link
Reference in a new issue