Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions tests/test_plain_dca_dependency.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,19 @@ def test_installed_api_preserves_final_tranche_and_preview_only(installed_dca_ca
assert evaluate_dca_period(**installed_dca_case) == result


def test_adapter_consumes_installed_api_and_rejects_sg(installed_dca_case):
def test_adapter_consumes_installed_api_and_rejects_sg(installed_dca_case, monkeypatch):
from us_equity_strategies.plain_dca import evaluate_dca_period

from application.plain_dca_paper_adapter import (
PlainDcaPaperError,
consume_plain_dca_preview,
)
from application.runtime_target_manifest import load_runtime_target_manifest
from types import SimpleNamespace

service, = [t.service for t in load_runtime_target_manifest().targets if t.id == "paper"]
service = "fake-paper-service"
paper = SimpleNamespace(id="paper", environment="longbridge-paper", mode="paper", service=service)
monkeypatch.setattr("application.plain_dca_paper_adapter.load_runtime_target_manifest",
lambda: SimpleNamespace(targets=(paper,)))
now = installed_dca_case["now"]
readback = {"observed_at": now, "valid_until": now+timedelta(minutes=1),
"target_id": "paper", "environment": "longbridge-paper",
Expand Down
12 changes: 10 additions & 2 deletions tests/test_plain_dca_paper_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@
NOW = datetime(2026, 11, 5, tzinfo=timezone.utc)


@pytest.fixture(autouse=True)
def synthetic_paper_manifest(monkeypatch):
paper = SimpleNamespace(id="paper", environment="longbridge-paper", mode="paper",
service="fake-paper-service")
monkeypatch.setattr("application.plain_dca_paper_adapter.load_runtime_target_manifest",
lambda: SimpleNamespace(targets=(paper,)))


@dataclass(frozen=True)
class Preview:
no_order: bool = True
Expand All @@ -30,11 +38,11 @@ def readback():
"target_id": "paper", "environment": "longbridge-paper",
"live_enabled": False, "kelly_enabled": False, "stop_loss_enabled": False,
"protected_env": {
"CLOUD_RUN_SERVICE": "longbridge-quant-paper-service",
"CLOUD_RUN_SERVICE": "fake-paper-service",
"RUNTIME_TARGET_ENABLED": "false", "LONGBRIDGE_DRY_RUN_ONLY": "false",
"LONGBRIDGE_PHYSICAL_ACCOUNT_ID": "fake-paper-account",
"RUNTIME_TARGET_JSON": json.dumps({
"platform_id": "longbridge", "service_name": "longbridge-quant-paper-service",
"platform_id": "longbridge", "service_name": "fake-paper-service",
"execution_environment": "paper", "dry_run_only": False,
"execution_mode": "live", "account_scope": "PAPER",
"account_selector": ["PAPER"], "deployment_selector": "PAPER",
Expand Down
11 changes: 9 additions & 2 deletions tests/test_plain_dca_paper_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,22 @@

from application.plain_dca_paper_adapter import PlainDcaPaperError
from application.plain_dca_paper_scheduler import scheduled_plain_dca_preview
from application.runtime_target_manifest import load_runtime_target_manifest

pytest_plugins = ("test_plain_dca_dependency",)

NOW = datetime(2026, 11, 5, tzinfo=timezone.utc)


@pytest.fixture(autouse=True)
def synthetic_paper_manifest(monkeypatch):
paper = SimpleNamespace(id="paper", environment="longbridge-paper", mode="paper",
service="fake-paper-service")
monkeypatch.setattr("application.plain_dca_paper_adapter.load_runtime_target_manifest",
lambda: SimpleNamespace(targets=(paper,)))


def readback():
service, = [t.service for t in load_runtime_target_manifest().targets if t.id == "paper"]
service = "fake-paper-service"
return {
"observed_at": NOW, "valid_until": NOW+timedelta(minutes=1),
"target_id": "paper", "environment": "longbridge-paper",
Expand Down
Loading