Пример #1
0
def test_client_initialization_with_invalid_requests_handler():
    with pytest.raises(RuntimeError) as exc_info:
        MinimalClient(
            authentication_method=NoAuthentication(),
            response_handler=MockResponseHandler,
            request_formatter=None,
        )
    assert str(exc_info.value) == "provided request_formatter must be a subclass of BaseRequestFormatter."
Пример #2
0
def test_client_initialization_with_invalid_authentication_method():
    with pytest.raises(RuntimeError) as exc_info:
        MinimalClient(
            authentication_method=None,
            response_handler=MockResponseHandler,
            request_formatter=MockRequestFormatter,
        )
    expected_message = "provided authentication_method must be an instance of BaseAuthenticationMethod."
    assert str(exc_info.value) == expected_message
Пример #3
0
def test_client_initialization_with_invalid_request_strategy():
    with pytest.raises(RuntimeError) as exc_info:
        MinimalClient(
            authentication_method=NoAuthentication(),
            response_handler=MockResponseHandler,
            request_formatter=MockRequestFormatter,
            request_strategy=object(),
        )
    assert str(
        exc_info.value
    ) == "provided request_strategy must be an instance of BaseRequestStrategy."
Пример #4
0
def test_get_request_strategy_with_user_defined():
    custom_request_strategy = BaseRequestStrategy()
    client = MinimalClient(request_strategy=custom_request_strategy)
    assert client.get_request_strategy() is custom_request_strategy
Пример #5
0
def test_get_authentication_method_with_user_defined():
    custom_authentication_method = BaseAuthenticationMethod()
    client = MinimalClient(authentication_method=custom_authentication_method)
    assert client.get_authentication_method() is custom_authentication_method