From 3f76726c3b2f3f934bffb248c520e375d12f6cad Mon Sep 17 00:00:00 2001 From: Georg-Stahn Date: Thu, 30 Nov 2023 20:21:01 +0100 Subject: [PATCH] =?UTF-8?q?adding=20more=20typing=20stuff=20but=20struggel?= =?UTF-8?q?ing=20with=20expected=20typing=20and=20running=20code=20for=20p?= =?UTF-8?q?ytest=20:'):=20api.post(data=3D=3F=3F=3F=3F)?= --- pkgs/clan-cli/tests/test_db_api.py | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/pkgs/clan-cli/tests/test_db_api.py b/pkgs/clan-cli/tests/test_db_api.py index 581ef7c..eb1f574 100644 --- a/pkgs/clan-cli/tests/test_db_api.py +++ b/pkgs/clan-cli/tests/test_db_api.py @@ -1,4 +1,5 @@ import json +from typing import Collection, Iterable, Mapping, Union from api import TestClient @@ -6,7 +7,16 @@ default_entity_did_url = "entity_did=did%3Asov%3Atest%3A1234" default_entity_did = "did:sov:test:1234" -def assert_extra_info(infos: list(), request_body: dict(), response: dict()) -> None: +def assert_extra_info( + infos: list[str], + request_body: Union[ + dict[str, object], + dict[str, Collection[str]], + Mapping[str, Union[str, Iterable[str]]], + ], + response: dict[str, str], +) -> None: + # print(type()) for info in infos: assert info in response.keys() # TODO maybe check the content of the extra info ... @@ -15,12 +25,20 @@ def assert_extra_info(infos: list(), request_body: dict(), response: dict()) -> def make_test_post_and_get( - api: TestClient, request_body: dict(), paramter: str, get_request=default_entity_did_url: str, apiversion="v1": str + api: TestClient, + request_body: Union[ + dict[str, object], + dict[str, Collection[str]], + Mapping[str, Union[str, Iterable[str]]], + ], + paramter: str, + get_request: str = default_entity_did_url, + apiversion: str = "v1", ) -> None: # test post response = api.post( f"/api/{apiversion}/create_{paramter}", - data=json.dumps(request_body), + data={"data": json.dumps(request_body)}, headers={"Content-Type": "application/json"}, ) assert response.status_code == 200