[#310] Added classmethod decorator in Http client

Signed-off-by: Dmitriy Zayakin <d.zayakin@yadro.com>
This commit is contained in:
Dmitriy Zayakin 2024-11-14 15:01:26 +03:00
parent f24bfc06fd
commit 4677709d13

View file

@ -50,6 +50,7 @@ class HttpClient:
return response return response
@classmethod
def _attach_response(self, response: httpx.Response): def _attach_response(self, response: httpx.Response):
request = response.request request = response.request
@ -88,6 +89,7 @@ class HttpClient:
reporter.attach(report, "Requests Info") reporter.attach(report, "Requests Info")
reporter.attach(curl_request, "CURL") reporter.attach(curl_request, "CURL")
@classmethod
def _create_curl_request(self, url: str, method: str, headers: httpx.Headers, data: str) -> str: def _create_curl_request(self, url: str, method: str, headers: httpx.Headers, data: str) -> str:
headers = " ".join(f'-H "{name.title()}: {value}"' for name, value in headers.items()) headers = " ".join(f'-H "{name.title()}: {value}"' for name, value in headers.items())
data = f" -d '{data}'" if data else "" data = f" -d '{data}'" if data else ""