← ClaudeAtlas

python-testinglisted

Unit-test code that calls the PayPal Server SDK Python SDK. Load before stubbing the SDK. The constructor won't tell you the seam is your own `requests.Session` passed as `http_client_instance` plus `http_call_back` for asserting the request, that `max_retries` is inert on a session you supply, or that an OAuth grant's token request traverses that same seam.
MuHamza30/paypal-api-plugin · ★ 0 · Testing & QA · score 70
Install: claude install-skill MuHamza30/paypal-api-plugin
# Testing code that uses an APIMatic Python SDK The SDK ships **no mocking helpers for consumers**. Its transport is `requests`, wrapped by `RequestsClient` from `apimatic-requests-client-adapter`, and the client exposes two seams on its constructor: | Argument | Use it for | | --- | --- | | `http_client_instance` | supplying your own `requests.Session` (or an `HttpClientProvider`) — the in-process seam: no network, no global patching | | `http_call_back` | observing the request and response the SDK actually produced — the assertion seam | The samples below use pytest-style plain `assert` for reference only — mirror whatever the project already uses. ## The response catcher — copy the SDK's own pattern `HttpCallBack` (`paypalserversdk/http/http_call_back.py`) has exactly two methods, called around every request: ```python from paypalserversdk.http.http_call_back import HttpCallBack class ResponseCatcher(HttpCallBack): def __init__(self): self.request = None self.response = None def on_before_request(self, request): self.request = request # HttpRequest: http_method, query_url, headers, # query_parameters, parameters, files def on_after_response(self, response): self.response = response # HttpResponse: status_code, reason_phrase, # headers, text, request ``` If the SDK shipped a `tests/` directory it already contains this class as `tests/http_res