Co-Authored-By: Quentin Torroba <quentin.torroba@mistral.ai> Co-Authored-By: Michel Thomazo <michel.thomazo@mistral.ai> Co-Authored-By: Clément Drouin <clement.drouin@mistral.ai> Co-Authored-By: Vincent Guilloux <vincent.guilloux@mistral.ai> Co-Authored-By: Clément Siriex <clement.sirieix@mistral.ai> Co-Authored-By: Kim-Adeline Miguel <kimadeline.miguel@mistral.ai> Co-Authored-By: Thaddee Tyl <thaddee.tyl@gmail.com> Co-Authored-By: David Brochart <david.brochart@gmail.com> Co-Authored-By: Joseph Guhlin <joseph.guhlin@gmail.com> Co-Authored-By: Thomas Kenbeek <thomaskenbeek@gmail.com> Co-Authored-By: Remenby31 <baptiste.cruvellier31@gmail.com>
32 lines
922 B
Python
32 lines
922 B
Python
from __future__ import annotations
|
|
|
|
from vibe.cli.plan_offer.ports.whoami_gateway import (
|
|
WhoAmIGatewayError,
|
|
WhoAmIGatewayUnauthorized,
|
|
WhoAmIResponse,
|
|
)
|
|
|
|
|
|
class FakeWhoAmIGateway:
|
|
def __init__(
|
|
self,
|
|
response: WhoAmIResponse | None = None,
|
|
*,
|
|
unauthorized: bool = False,
|
|
error: bool = False,
|
|
) -> None:
|
|
self._response = response
|
|
self._unauthorized = unauthorized
|
|
self._error = error
|
|
self.calls: list[str] = []
|
|
|
|
async def whoami(self, api_key: str) -> WhoAmIResponse:
|
|
self.calls.append(api_key)
|
|
if self._unauthorized:
|
|
raise WhoAmIGatewayUnauthorized()
|
|
if self._error:
|
|
raise WhoAmIGatewayError()
|
|
if self._response is None:
|
|
msg = "FakeWhoAmIGateway requires a response when no error is set."
|
|
raise RuntimeError(msg)
|
|
return self._response
|