fix(sp37): align submission router with package conventions

Code review of f1dc06e flagged 3 consistency outliers vs every other
gated router in api_routers/:

- Drop prefix='/api' from APIRouter. Every sibling (clearhouse,
  parse, claims, batches, inbox, acks, ta1_acks, claim_acks,
  remittances, providers, reconciliation, activity, eligibility,
  dashboard, admin, config, payers, acks) declares the full path
  in the decorator instead. Submission was the only one with
  prefix='/api' + '/submit-batch'.

- Rename handler post_submit_batch -> submit_batch. Siblings use
  verb_noun (submit_to_clearhouse, export_batch_837, etc.). The
  'post_' prefix was unique to this file.

- Move 'from cyclone.store import store as cycl_store' from inside
  the handler to the module top. Sibling routers all import store
  at module top — the lazy-import rationale in the inline comment
  was wrong; pulling store at module import time is fine (the rest
  of the package already does it).

Tests: tests/test_api_submit_batch.py + tests/test_submission.py +
tests/test_batch_txn_set_cn.py + tests/test_batch_envelope_index_sp37.py
= 26 passed in 1.37s (no behavior change, just naming).
This commit is contained in:
Nora
2026-07-07 11:42:07 -06:00
parent f1dc06ec3b
commit 4c85166734
@@ -32,13 +32,16 @@ from fastapi import APIRouter, Depends, HTTPException
from pydantic import BaseModel, ConfigDict, Field from pydantic import BaseModel, ConfigDict, Field
from cyclone.auth.deps import matrix_gate from cyclone.auth.deps import matrix_gate
from cyclone.store import store as cycl_store
from cyclone.submission.core import submit_file from cyclone.submission.core import submit_file
from cyclone.submission.result import SubmitOutcome, SubmitResult from cyclone.submission.result import SubmitOutcome, SubmitResult
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
# No `prefix=` here — every other gated router in this package declares
# the full path in the decorator (clearhouse.py uses "/api/clearhouse",
# parse.py uses "/api/parse-837", etc.). The decorator sets the full URL.
router = APIRouter( router = APIRouter(
prefix="/api",
tags=["submission"], tags=["submission"],
dependencies=[Depends(matrix_gate)], dependencies=[Depends(matrix_gate)],
) )
@@ -69,8 +72,8 @@ class SubmitBatchRequest(BaseModel):
limit: int | None = None limit: int | None = None
@router.post("/submit-batch") @router.post("/api/submit-batch")
def post_submit_batch(body: SubmitBatchRequest): def submit_batch(body: SubmitBatchRequest):
"""Submit every ``batch-*-claims/*.x12`` under ``ingest_dir``. """Submit every ``batch-*-claims/*.x12`` under ``ingest_dir``.
Walks ``ingest_dir`` for any directory matching ``batch-*-claims``, Walks ``ingest_dir`` for any directory matching ``batch-*-claims``,
@@ -84,7 +87,6 @@ def post_submit_batch(body: SubmitBatchRequest):
HTTP status code — the response is 200 whenever the run itself HTTP status code — the response is 200 whenever the run itself
completed. completed.
""" """
from cyclone.store import store as cycl_store
# 1. Config-level guards. Order matters: a missing clearhouse is a # 1. Config-level guards. Order matters: a missing clearhouse is a
# 404 (config-level "missing"), but if it IS present and in stub # 404 (config-level "missing"), but if it IS present and in stub