Repository navigation
Overhaul E2E tests: dynamic dates and strict error handling - #11
Merged
Merged
Conversation
The suite relied on a hardcoded trading day (20250613), which would break for every date-based test once it left a plan's data retention window. TestMain now resolves recent trading days via the trading calendar API (weekday fallback if unavailable) with a configurable lag (JQUANTS_TEST_LAG_DAYS, rejected loudly when invalid). When no lag is specified, a one-shot probe against the daily quotes API detects delayed plans (valid queries return empty data, never an error) and falls back to a 13-week lag so Free-plan runs still exercise the endpoints; probe errors fail the run instead of being misdiagnosed as a plan limitation.
Eleven subtests logged API errors and returned silently, so they never verified their success paths (the pattern that hid the invalid indices query fixed earlier). Unexpected errors now fail the test; skips remain only for subscription limits and legitimately empty datasets, since the API returns 200 with empty data rather than 4xx when a valid query has no data. Event-driven datasets no longer depend on the run date: statements and fs_details resolve a recent disclosure day via findPopulatedTestDate, and the investor-types single-day query targets the latest publication date found in a 30-day range (from/to filter on publication date), failing instead of skipping when that date returns nothing. This surfaced two dead spots: section "All" is not a valid investor-types section (now TokyoNagoya) and the single-day query never matched period dates. Also derive the daily margin interest range start from the resolved test date instead of a fixed 20250601.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要
E2Eテストの2つの構造的問題を解消する: 固定テスト日付(20250613)による将来の一斉破損と、エラー握りつぶしによる「成功パスを一度も検証していないテスト」の混在。
背景
indices のテストが仕様上必ず400になるリクエストを
t.Logf+returnで握りつぶしており、一度も成功パスを通っていなかったことが PR #9 で発覚した。同じパターンが他に11箇所存在し、また固定日付はプランのデータ保持期間を外れた時点で日付ベースの全テストを壊す。変更内容
テスト日付の動的解決
TestMainで取引カレンダーAPIから直近の営業日一覧を取得し、テスト基準日を動的に決定(取得失敗時は土日を除く平日にフォールバック)JQUANTS_TEST_LAG_DAYSで明示指定可能(不正値はpanicで即失敗)。未指定時は株価APIへの軽量プローブでデータ遅延プラン(Free=12週遅延)を自動検出し、13週ラグに切り替える。プローブのエラーは遅延と誤診せず即失敗させる20250601)も基準日からの相対指定に変更エラーハンドリングの厳格化(11箇所)
t.Fatalfに変更し、Skipはサブスクリプション制限と正当な空データのみに限定listedの InvalidCode テストは異常系として正当なため維持イベント駆動データセットの検証強化
findPopulatedTestDateで直近5営業日から開示のある日を解決。実行日依存のSkipを排除"All"は無効値で永遠に0件→Skipだった(有効なTokyoNagoyaに変更し、523件を実際に検証)テスト