Skip to content

Commit ff185d0

Browse files
Minor Api testing improvements (#8687)
* Add missing backtests/read null check * Improve SPDB error message
1 parent e903096 commit ff185d0

3 files changed

Lines changed: 14 additions & 2 deletions

File tree

Api/Api.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,12 @@ public Backtest ReadBacktest(int projectId, string backtestId, bool getCharts =
525525

526526
ApiConnection.TryRequest(request, out BacktestResponseWrapper result);
527527

528+
if (result == null)
529+
{
530+
// api call failed
531+
return null;
532+
}
533+
528534
if (!result.Success)
529535
{
530536
// place an empty place holder so we can return any errors back to the user and not just null

Common/Messages/Messages.Securities.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -924,7 +924,7 @@ public static class SecurityService
924924
[MethodImpl(MethodImplOptions.AggressiveInlining)]
925925
public static string SymbolNotFoundInSymbolPropertiesDatabase(QuantConnect.Symbol symbol)
926926
{
927-
return $"Symbol could not be found in the Symbol Properties Database: {symbol.Value}";
927+
return $"{symbol.SecurityType} '{symbol.Value}' symbol could not be found in the database for {symbol.ID.Market} market";
928928
}
929929
}
930930

Tests/Api/ApiTestBase.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,13 @@ public static Backtest WaitForBacktestCompletion(Api.Api apiClient, int projectI
178178
{
179179
Thread.Sleep(1000);
180180
backtest = apiClient.ReadBacktest(projectId, backtestId);
181-
if (backtest != null && (!string.IsNullOrEmpty(backtest.Error) || backtest.HasInitializeError))
181+
if (backtest == null)
182+
{
183+
// api failed, let's retry
184+
continue;
185+
}
186+
187+
if (!string.IsNullOrEmpty(backtest.Error) || backtest.HasInitializeError)
182188
{
183189
Assert.Fail($"Backtest {projectId}/{backtestId} failed: {backtest.Error}. Stacktrace: {backtest.Stacktrace}. Api errors: {string.Join(",", backtest.Errors)}");
184190
}

0 commit comments

Comments
 (0)