Exemplo n.º 1
0
def test_get_attaches_parameters_to_url(requests_mock: RequestsMock) -> None:
    requests_mock.add(requests_mock.GET, API_BASE_URL + "endpoint", '{ "success": true }')

    api = APIClient(mock.Mock(), "123", "456")
    api.get("endpoint", {"key1": "value1", "key2": "value2"})

    assert len(requests_mock.calls) == 1
    assert requests_mock.calls[0].request.url == API_BASE_URL + "endpoint?key1=value1&key2=value2"
Exemplo n.º 2
0
def test_get_makes_get_request_to_given_endpoint(requests_mock: RequestsMock) -> None:
    requests_mock.add(requests_mock.GET, API_BASE_URL + "endpoint", '{ "success": true }')

    api = APIClient(mock.Mock(), "123", "456")
    api.get("endpoint")

    assert len(requests_mock.calls) == 1
    assert requests_mock.calls[0].request.url == API_BASE_URL + "endpoint"