コード例 #1
0
    def from_result(result: Result):
        if result.is_success:
            response = result.unwrap()
            return WebhookResponseResult(
                headers=response.headers,
                body=response.content,
                status_code=response.status_code,
                completed_in_ms=response.completed_in_ms,
            )

        error = result.value
        return WebhookResponseResult(
            headers=error.headers,
            body=error.content,
            status_code=error.status_code,
            completed_in_ms=error.completed_in_ms,
        )
コード例 #2
0
def test_should_return_the_value_when_unwrap_a_success_result():

    result = Result(success="Hi!")
    value = result.unwrap()

    assert value == "Hi!"