541682fa4e
Python Virtual Environments / build (push) Has been cancelled
Benchmarks / build (push) Has been cancelled
Build & Test Lean / build (push) Has been cancelled
Regression Tests / build (push) Has been cancelled
Research Regression Tests / build (push) Has been cancelled
Syntax Tests / build (push) Has been cancelled
Report Generator Tests / build (push) Has been cancelled
API Tests / build (push) Has been cancelled
* feat: add CreateOAuthTokenHandler factory to Brokerage base class Introduce AuthenticationFailed event on TokenHandler raised when all retry attempts are exhausted. Add CreateOAuthTokenHandler<TRequest,TResponse> protected factory method on Brokerage that wires the event to OnMessage (BrokerageMessageType.Error), triggering graceful Lean shutdown on OAuth token refresh failure without requiring per-brokerage error logic. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * refactor: token retry logic: move to OAuthTokenHandler * refactor: replace generic OAuthTokenHandler with non-generic, require explicit token lifetime - Remove generic type parameters <TRequest, TResponse> from OAuthTokenHandler and CreateOAuthTokenHandler; use LeanAccessTokenMetaDataRequest and AccessTokenMetaDataResponse directly - Delete abstract AccessTokenMetaDataRequest; logic moved to LeanAccessTokenMetaDataRequest - Make tokenLifetime a required constructor parameter — each brokerage must explicitly declare its OAuth token lifetime to prevent silent 1-hour fallback bugs - Move expiry tracking into the handler via _tokenExpiresAt (written under lock before the volatile write of _tokenCredentials, ensuring correct visibility on the fast path) - Simplify AccessTokenMetaDataResponse to a concrete class with { get; set; } properties Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * test: add unit tests for OAuthTokenHandler and AccessTokenMetaDataResponse - Make ApiConnection.TryRequest<T>(HttpRequestMessage) virtual to allow test subclasses to intercept without real HTTP calls - Add AccessTokenMetaDataResponseTests: two parameterized cases verify that TokenType defaults to Bearer when absent from JSON (CharlesSchwab pattern) and deserializes correctly when present (Tastytrade pattern) - Add OAuthTokenHandlerTests with FakeApiConnection stub: CharlesSchwab-style response (no tokenType, 30-min lifetime) and Tastytrade-style response (explicit tokenType + expiresIn/tokenId, 15-min lifetime) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * refactor: backward-compatible OAuth auth with new LeanOAuthTokenHandler hierarchy - Restore master API: OAuthTokenHandler<TReq,TRes>, AccessTokenMetaDataRequest, AccessTokenMetaDataResponse, and TokenHandler stay source-compatible for old consumers - Extend TokenHandler with AuthenticationFailed event; simplify Send() (auth header only) - Add LeanOAuthTokenHandler: non-generic, thread-safe double-checked locking, explicit tokenLifetime, retry logic in GetAccessToken, fires AuthenticationFailed on exhaustion - Add OAuthTokenRequest / OAuthTokenResponse: concrete Lean platform request/response - Brokerage.CreateOAuthTokenHandler wires AuthenticationFailed to graceful shutdown - Update tests: OAuthTokenResponseTests, LeanOAuthTokenHandlerTests, TokenHandlerTests Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Some tweaks --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com> Co-authored-by: Martin Molinero <martin.molinero1@gmail.com>
QuantConnect Testing
Before starting any testing, follow the installation instructions to get LEAN running C# algorithms in your machine. For any Python related tests please ensure you have followed the setup as described here.
If the above installation, build, and initial run was successful than we can move forward to testing.
Visual Studio:
Locating Tests
- Open Visual Studios
- Open Test Explorer ("Test" > "Test Explorer")
- The list should populate itself as it reads all the tests it found during the build process. If not, press "Run All Tests" and let VS find all of the tests.
- From here select the tests you would like to run and begin running them.
Failed Test Logs
- On a failed test, check the test for information by clicking on the desired test and selecting "Open Additional Output"
- This will show the stack trace and where the code failed to meet the testing requirements.
Common Problems
Having .NetFramework issues with testing?
- Install NUnit3TestAdapter for VS
Missing dependencies for Python Algorithm?
- Use pip or conda to install the module.