From df0ac363836dff3f1accf6da316e14138b4dea74 Mon Sep 17 00:00:00 2001 From: Kirill Sosnovskikh Date: Thu, 5 Dec 2024 14:17:25 +0300 Subject: [PATCH] Fix `files` param in http client Signed-off-by: Kirill Sosnovskikh --- src/frostfs_testlib/http/http_client.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/frostfs_testlib/http/http_client.py b/src/frostfs_testlib/http/http_client.py index 0d1e0bd..6008989 100644 --- a/src/frostfs_testlib/http/http_client.py +++ b/src/frostfs_testlib/http/http_client.py @@ -2,7 +2,7 @@ import io import json import logging import logging.config -from typing import IO +from typing import Mapping, Sequence import httpx @@ -84,13 +84,20 @@ class HttpClient: return request_body @classmethod - def _parse_files(cls, files: dict | None) -> str | None: + def _parse_files(cls, files: Mapping | Sequence | None) -> str | None: if not files: return None filepaths = {} - for name, file in files.items(): + if isinstance(files, Sequence): + items = files + elif isinstance(files, Mapping): + items = files.items() + else: + raise TypeError(f"'files' must be either Sequence or Mapping, got: {type(files).__name__}") + + for name, file in items: if isinstance(file, io.IOBase): filepaths[name] = file.name