IbkrApi.Support.HTTPMockHelper (ibkr_api v1.0.3)

View Source

Helper module for using HTTP mocks in tests.

DEPRECATED: This module is deprecated in favor of using HTTPSandbox and the explicit stub modules.

Use the stub modules directly instead:

alias IbkrApi.Support.HTTPStubs.{AuthStub, TradeStub, ContractStub, MarketDataStub, PortfolioStub, OrderStub}

# Register stubs in your test
test "example test" do
  AuthStub.stub_auth_status()
  TradeStub.stub_list_trades()
  
  # Make your assertions
end

See the documentation in guides/how-to/testing_with_http_mocks.md for more details.

@deprecated "Use HTTPSandbox and explicit stub modules instead"

Summary

Functions

Macro that imports the helper functions for HTTP mocking.

Mocks an HTTP function for a specific module.

Reset all HTTP mocks to their original implementations.

Functions

__using__(opts)

(macro)

Macro that imports the helper functions for HTTP mocking.

mock_http(module_key, function_name, custom_response \\ nil)

Mocks an HTTP function for a specific module.

Parameters

  • module_key: The module key (:auth, :trade, :contract, :market_data, :portfolio, :order)
  • function_name: The name of the stub function to use (e.g. :stub_list_trades)
  • custom_response: Optional custom response function

Examples

mock_http(:trade, :stub_list_trades)
mock_http(:auth, :stub_auth_status, my_custom_response_fn)

reset_http_mocks()

Reset all HTTP mocks to their original implementations.

@deprecated "Use HTTPSandbox.reset() instead"