Files
fxhnt/tests/integration/test_orchestration_definitions.py
jgrusewski 2e391489bf feat(b1): wire 6 paper-track assets into the Dagster graph
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-16 08:18:12 +02:00

36 lines
2.0 KiB
Python

"""The Definitions load and expose a daily schedule over the combined-book asset job + the 4 assets."""
from __future__ import annotations
def test_definitions_load_with_assets_and_schedule() -> None:
from fxhnt.adapters.orchestration.definitions import defs
# --- assets present ---
# defs.get_repository_def() is available in Dagster 1.12; its .assets_defs_by_key
# maps AssetKey → AssetsDefinition for every registered asset.
repo = defs.get_repository_def()
asset_keys = {k.to_user_string() for k in repo.assets_defs_by_key}
assert {"crypto_bars", "futures_bars", "combined_forward_nav", "cockpit_forward"} <= asset_keys
# B1: the six paper-track assets are wired into the graph alongside the B0 four
paper = {"sixtyforty_nav", "multistrat_nav", "gd_nav", "funding_nav", "crossvenue_nav", "poc_nav"}
assert paper <= asset_keys, f"missing paper-track assets: {paper - asset_keys}"
# --- schedule present with the right cron ---
# defs.schedules is a list[ScheduleDefinition] (or None when empty)
scheds = list(defs.schedules or [])
assert any(getattr(s, "cron_schedule", "") == "30 23 * * *" for s in scheds), (
f"expected a schedule with cron '30 23 * * *'; got {[getattr(s, 'cron_schedule', None) for s in scheds]}"
)
# auto-arm on fresh deploy — else a recreated instance silently never runs the nightly track
from dagster import DefaultScheduleStatus
daily = next(s for s in scheds if getattr(s, "cron_schedule", "") == "30 23 * * *")
assert daily.default_status == DefaultScheduleStatus.RUNNING
# --- cockpit_forward depends on every paper-track asset (so it ingests their state files) ---
from dagster import AssetKey
cockpit_def = repo.assets_defs_by_key[AssetKey("cockpit_forward")]
deps = cockpit_def.asset_deps[AssetKey("cockpit_forward")]
upstream = {k.to_user_string() for k in deps}
expected_upstream = {"combined_forward_nav"} | paper
assert expected_upstream <= upstream, f"cockpit_forward missing upstream: {expected_upstream - upstream}"