Exemple #1
0
def test_api_post_fail(resp: RequestsMock, api: Api, body: Any, status: Any,
                       expectation: Any) -> None:

    resp.add(responses.POST, url=api.url, body=body, status=status)

    with expectation:
        api.post(api.url, {})
Exemple #2
0
def test_api_post_success(resp: RequestsMock, api: Api,
                          json_dict: Any) -> None:
    url = f"{api.url}test"

    resp.add(
        responses.POST,
        url=url,
        json=json_dict,
        match=[responses.json_params_matcher(json_dict)],
        status=200,
    )

    assert api.post(url, json_dict) == json_dict