This commit is contained in:
@@ -353,3 +353,40 @@ async def test_scoped_date_query_parameters_and_no_platform_check(settings):
|
||||
assert "status!" in second and second["hidden"] == "true"
|
||||
assert all(r.method == "GET" and r.url.path == "/users/self/alphas" for r in requests)
|
||||
await client.close()
|
||||
|
||||
|
||||
@pytest.mark.parametrize("region", ["USA", None])
|
||||
async def test_empty_region_reference_set_passes_with_zero_but_missing_region_does_not(
|
||||
app, logged_in, region
|
||||
):
|
||||
runner = app.state.runner # No credentials or PnL; this branch must stay local.
|
||||
async with runner.sessions.begin() as db:
|
||||
for raw in (
|
||||
alpha("target", settings={"region": region}),
|
||||
alpha("pending", settings={"region": "USA"}),
|
||||
alpha("other-region", status="ACTIVE", settings={"region": "CHN"}),
|
||||
):
|
||||
await upsert_alpha(db, raw)
|
||||
job = (
|
||||
await logged_in.post(
|
||||
f"{PREFIX}/sync-jobs", json={"kind": "self_correlation", "alpha_ids": ["target"]}
|
||||
)
|
||||
).json()
|
||||
await runner.execute(job["id"])
|
||||
assert (await result(runner, job["id"])).status == "completed"
|
||||
report = (await logged_in.get(f"{PREFIX}/alphas/target/self-correlation")).json()["result"]
|
||||
assert report["candidate_count"] == report["compared_count"] == report["skipped_count"] == 0
|
||||
assert report["status"] == ("low" if region else "insufficient_data")
|
||||
assert report["max_correlation"] == (0.0 if region else None)
|
||||
assert not report["stale"] and report["matches"] == []
|
||||
summary = (await logged_in.get(f"{PREFIX}/alphas?q=target")).json()["items"][0]["local_correlation"]
|
||||
assert summary["status"] == report["status"]
|
||||
assert summary["max_correlation"] == report["max_correlation"]
|
||||
state = (await logged_in.get(f"{PREFIX}/alphas/target/submission")).json()
|
||||
assert state["can_check"] is bool(region)
|
||||
if region:
|
||||
async with runner.sessions.begin() as db:
|
||||
await upsert_alpha(db, alpha("new-peer", status="ACTIVE"))
|
||||
report = (await logged_in.get(f"{PREFIX}/alphas/target/self-correlation")).json()["result"]
|
||||
assert report["stale"]
|
||||
assert not (await logged_in.get(f"{PREFIX}/alphas/target/submission")).json()["can_check"]
|
||||
|
||||
Reference in New Issue
Block a user