From 7c93713629d5c8e9eb6baa351850d5d1e4c5a2ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Herv=C3=A9?= Date: Thu, 18 Jan 2024 16:17:19 +0100 Subject: [PATCH] Add support for file parameters --- tests/conftest.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 56538f330b..91a1177b1b 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -55,7 +55,7 @@ def pytest_terminal_summary(terminalreporter, exitstatus, config): from datadog_api_client import exceptions from datadog_api_client.api_client import ApiClient from datadog_api_client.configuration import Configuration -from datadog_api_client.model_utils import OpenApiModel +from datadog_api_client.model_utils import OpenApiModel, file_type logging.basicConfig() @@ -581,7 +581,13 @@ def execute_request(undo, context, client, api_version, request): params_map = getattr(api_request["api"], f'_{api_request["request"].__name__}_endpoint').params_map for k, v in api_request["kwargs"].items(): - api_request["kwargs"][k] = client.deserialize(v, params_map[k]["openapi_types"], True) + openapi_types = params_map[k]["openapi_types"] + if openapi_types == (file_type,): + filepath = os.path.join(os.path.dirname(__file__), api_version, "features", json.loads(v)) + # We let the GC collects it, this shouldn't be an issue + api_request["kwargs"][k] = open(filepath) + else: + api_request["kwargs"][k] = client.deserialize(v, openapi_types, True) try: response = api_request["request"](*api_request["args"], **api_request["kwargs"])