adding more typing stuff but struggeling with expected typing and running code for pytest :'): api.post(data=????)

This commit is contained in:
Georg-Stahn
2023-11-30 20:21:01 +01:00
parent 243474dc9a
commit 3f76726c3b

View File

@@ -1,4 +1,5 @@
import json import json
from typing import Collection, Iterable, Mapping, Union
from api import TestClient 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" 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: for info in infos:
assert info in response.keys() assert info in response.keys()
# TODO maybe check the content of the extra info ... # 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( 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: ) -> None:
# test post # test post
response = api.post( response = api.post(
f"/api/{apiversion}/create_{paramter}", f"/api/{apiversion}/create_{paramter}",
data=json.dumps(request_body), data={"data": json.dumps(request_body)},
headers={"Content-Type": "application/json"}, headers={"Content-Type": "application/json"},
) )
assert response.status_code == 200 assert response.status_code == 200