From 9d113ed860aaf3cae142b3bd9ee40e8690dc9e03 Mon Sep 17 00:00:00 2001 From: Roman Reznikov Date: Mon, 11 Jul 2022 21:07:08 +0400 Subject: [PATCH] #19: test(fix): fix API client for unit tests - add `X-Request-Id` header --- tests/unit/testlib.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/unit/testlib.py b/tests/unit/testlib.py index 1ff24e4..97c064e 100644 --- a/tests/unit/testlib.py +++ b/tests/unit/testlib.py @@ -18,6 +18,11 @@ class APIClient(TestClient): def __init__(self, *args, **kwargs): super(APIClient, self).__init__(*args, **kwargs) + async def _request(self, method: str, path: str, **kwargs: Any) -> ClientResponse: + headers = kwargs.pop("headers", {}) + headers.update({"X-Request-Id": "XXX-XXX-XXX"}) + return await super(APIClient, self)._request(method, path, headers=headers, **kwargs) + async def head(self, *args, **kwargs) -> APIResponse: return await self._api_call("head", kwargs.get("expected_status_code", 200), *args, **kwargs)