Align branding, prompts, and deployment tooling

This commit is contained in:
2026-03-28 22:16:56 +08:00
parent 4aa69650e8
commit 4295293a21
90 changed files with 1320 additions and 2044 deletions

View File

@@ -0,0 +1,81 @@
# -*- coding: utf-8 -*-
"""Tests for market ingest watermark handling."""
from backend.data import market_ingest
class _FakeStore:
def __init__(self, *, last_news_fetch=None, latest_news_date=None):
self._watermarks = {
"symbol": "AAPL",
"last_price_fetch": None,
"last_news_fetch": last_news_fetch,
}
self._latest_news_date = latest_news_date
self.updated = []
def get_ticker_watermarks(self, symbol):
return dict(self._watermarks)
def get_latest_news_date(self, symbol):
return self._latest_news_date
def upsert_ticker(self, **kwargs):
return None
def upsert_ohlc(self, symbol, rows, source="polygon"):
return len(rows)
def upsert_news(self, symbol, rows, source="polygon"):
return len(rows)
def update_fetch_watermark(self, **kwargs):
self.updated.append(kwargs)
def test_refresh_news_incremental_does_not_advance_watermark_without_news(monkeypatch):
store = _FakeStore(last_news_fetch="2026-03-28", latest_news_date="2026-03-28")
monkeypatch.setattr(market_ingest, "fetch_ticker_details", lambda ticker: {"name": ticker, "sic_description": None, "active": True})
class _Router:
def get_company_news(self, **kwargs):
return [], "polygon"
monkeypatch.setattr(market_ingest, "DataProviderRouter", lambda: _Router())
monkeypatch.setattr(market_ingest, "align_news_for_symbol", lambda store, ticker: 0)
result = market_ingest.refresh_news_incremental(
"AAPL",
end_date="2026-03-29",
store=store,
)
assert result["start_news_date"] == "2026-03-29"
assert result["news"] == 0
assert store.updated[-1]["news_date"] is None
def test_refresh_news_incremental_clamps_future_watermark_to_latest_stored_date(monkeypatch):
store = _FakeStore(last_news_fetch="2026-03-30", latest_news_date="2026-03-28")
captured = {}
monkeypatch.setattr(market_ingest, "fetch_ticker_details", lambda ticker: {"name": ticker, "sic_description": None, "active": True})
class _Router:
def get_company_news(self, **kwargs):
captured.update(kwargs)
return [], "polygon"
monkeypatch.setattr(market_ingest, "DataProviderRouter", lambda: _Router())
monkeypatch.setattr(market_ingest, "align_news_for_symbol", lambda store, ticker: 0)
result = market_ingest.refresh_news_incremental(
"AAPL",
end_date="2026-03-29",
store=store,
)
assert result["start_news_date"] == "2026-03-29"
assert captured["start_date"] == "2026-03-29"
assert captured["end_date"] == "2026-03-29"