Skip to main content
View module source on GitHub Test case to simulate RemoteDisconnected connection errors and verify retry logic. This test demonstrates how the improved connection pool and retry logic in maxim_apis.py handles connection issues that users were experiencing.

TestConnectionRetryLogic

class TestConnectionRetryLogic(unittest.TestCase)
Test cases for connection retry logic improvements.

setUp

def setUp()
Set up test fixtures.

test_connection_pool_configuration

def test_connection_pool_configuration()
Test that connection pool is configured with improved settings.

test_remote_disconnected_retry_success

@patch("maxim.apis.maxim_apis.scribe")
@patch("time.sleep")
def test_remote_disconnected_retry_success(mock_sleep, mock_scribe)
Test that RemoteDisconnected errors are retried and eventually succeed.

test_pool_error_retry_logic

@patch("maxim.apis.maxim_apis.scribe")
@patch("time.sleep")
def test_pool_error_retry_logic(mock_sleep, mock_scribe)
Test that PoolError has separate retry logic with different parameters.

test_http_error_no_retry

@patch("maxim.apis.maxim_apis.scribe")
@patch("time.sleep")
def test_http_error_no_retry(mock_sleep, mock_scribe)
Test that HTTP errors are not retried (permanent failures).

test_max_retries_exhausted

@patch("maxim.apis.maxim_apis.scribe")
@patch("time.sleep")
def test_max_retries_exhausted(mock_sleep, mock_scribe)
Test behavior when max retries are exhausted.

test_exponential_backoff_timing

@patch("maxim.apis.maxim_apis.scribe")
@patch("time.sleep")
def test_exponential_backoff_timing(mock_sleep, mock_scribe)
Test that exponential backoff timing is correct.

test_file_upload_remote_disconnected_retry

@patch("maxim.apis.maxim_apis.scribe")
@patch("time.sleep")
@patch("requests.put")
def test_file_upload_remote_disconnected_retry(mock_put, mock_sleep,
                                               mock_scribe)
Test that file upload handles RemoteDisconnected errors with retry logic.

test_file_upload_http_error_no_retry

@patch("maxim.apis.maxim_apis.scribe")
@patch("time.sleep")
@patch("requests.put")
def test_file_upload_http_error_no_retry(mock_put, mock_sleep, mock_scribe)
Test that file upload HTTP errors are not retried.

test_api_method_with_connection_error

@patch("maxim.apis.maxim_apis.scribe")
def test_api_method_with_connection_error(mock_scribe)
Test that actual API methods handle connection errors properly.

test_different_connection_errors_are_caught

def test_different_connection_errors_are_caught()
Test that various connection-related errors are properly caught in our exception handling.

test_unexpected_exception_handling

@patch("maxim.apis.maxim_apis.scribe")
def test_unexpected_exception_handling(mock_scribe)
Test that unexpected exceptions are properly logged and re-raised.

test_request_exception_retry_logic

@patch("maxim.apis.maxim_apis.scribe")
@patch("time.sleep")
def test_request_exception_retry_logic(mock_sleep, mock_scribe)
Test that general RequestException errors are retried.

test_custom_retry_parameters

@patch("maxim.apis.maxim_apis.scribe")
@patch("time.sleep")
def test_custom_retry_parameters(mock_sleep, mock_scribe)
Test retry logic with custom parameters.

test_connection_pool_session_context_manager

def test_connection_pool_session_context_manager()
Test that the connection pool context manager works correctly.

test_version_check_during_retry

@patch("maxim.apis.maxim_apis.scribe")
@patch("time.sleep")
def test_version_check_during_retry(mock_sleep, mock_scribe)
Test that version checking works correctly during retry scenarios.

TestFileUploadRetryLogic

class TestFileUploadRetryLogic(unittest.TestCase)
Separate test class for file upload specific retry logic.

setUp

def setUp()
Set up test fixtures.

test_file_upload_extended_timeout

@patch("requests.put")
@patch("time.sleep")
@patch("maxim.apis.maxim_apis.scribe")
def test_file_upload_extended_timeout(mock_scribe, mock_sleep, mock_put)
Test that file uploads use extended timeouts.

test_file_upload_retry_exhaustion

@patch("requests.put")
@patch("time.sleep")
@patch("maxim.apis.maxim_apis.scribe")
def test_file_upload_retry_exhaustion(mock_scribe, mock_sleep, mock_put)
Test file upload behavior when all retries are exhausted.
I