Esempio n. 1
0
def mock_metadata():
    return BravadoResponseMetadata(
        incoming_response=None,
        swagger_result=None,
        start_time=5,
        request_end_time=6,
        handled_exception_info=None,
        request_config=None,
    )
Esempio n. 2
0
def mock_metadata():
    return BravadoResponseMetadata(
        incoming_response=IncomingResponse(),
        swagger_result=None,
        start_time=5,
        request_end_time=6,
        handled_exception_info=None,
        request_config=RequestConfig({}, also_return_response_default=False),
    )
Esempio n. 3
0
def test_response_metadata_times():
    with mock.patch('monotonic.monotonic', return_value=11):
        metadata = BravadoResponseMetadata(
            incoming_response=None,
            swagger_result=None,
            start_time=5,
            request_end_time=10,
            handled_exception_info=None,
            request_config=None,
        )

    assert metadata.elapsed_time == 6
    assert metadata.request_elapsed_time == 5
 def __init__(self, exception=BravadoTimeoutError(), metadata=None):
     self._exception = exception
     if metadata:
         self._metadata = metadata
     else:
         self._metadata = BravadoResponseMetadata(
             incoming_response=None,
             swagger_result=None,  # we're going to set it later
             start_time=1528733800,
             request_end_time=1528733801,
             handled_exception_info=(self._exception.__class__, self._exception, 'Traceback'),
             request_config=None,
         )
 def __init__(self, result, metadata=None):
     self._result = result
     if metadata:
         self._metadata = metadata
     else:
         self._metadata = BravadoResponseMetadata(
             incoming_response=IncomingResponseMock(status_code=200),
             swagger_result=self._result,
             start_time=1528733800,
             request_end_time=1528733801,
             handled_exception_info=None,
             request_config=None,
         )
Esempio n. 6
0
 def __init__(self, result, metadata=None):
     # type: (T, typing.Optional[BravadoResponseMetadata[T]]) -> None
     self._result = result
     if metadata:
         self._metadata = metadata
     else:
         self._metadata = BravadoResponseMetadata(
             incoming_response=IncomingResponseMock(status_code=200),
             swagger_result=self._result,
             start_time=1528733800,
             request_end_time=1528733801,
             handled_exception_info=None,
             request_config=RequestConfig(
                 {}, also_return_response_default=False),
         )
Esempio n. 7
0
 def __init__(self, exception=BravadoTimeoutError(), metadata=None):
     # type: (BaseException, typing.Optional[BravadoResponseMetadata]) -> None
     self._exception = exception
     if metadata:
         self._metadata = metadata
     else:
         self._metadata = BravadoResponseMetadata(
             incoming_response=IncomingResponse(),
             swagger_result=None,  # we're going to set it later
             start_time=1528733800,
             request_end_time=1528733801,
             handled_exception_info=[
                 self._exception.__class__, self._exception, 'Traceback'
             ],
             request_config=RequestConfig(
                 {}, also_return_response_default=False),
         )