fix(norms): templates grade by the cutoffs when handed no grade; the parts test reads inside transactions (#5742)
CI / lint (push) Successful in 2s
CI / integration (push) Successful in 1m18s
CI / unit (push) Successful in 1m25s
CI / publish (push) Successful in 1m11s

CI 9128: the host vitals and monitor templates required the new grades, so
callers (and tests) that render them without one failed; they now fall back
to status_class. The new integration test read outside begin(), which
autobegan the session.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-14 16:20:08 -04:00
co-authored by Claude Opus 5.5
parent f3433fe3ce
commit 7c23360bc7
4 changed files with 17 additions and 11 deletions
+8 -4
View File
@@ -360,15 +360,19 @@ def test_a_metric_learned_without_its_parts_ignores_them(app, src):
s.add_all(rows)
async with s.begin():
await rebuild_norms(s, NOW)
learned = await norms_at(s, [(src, host, METRIC), (src, part, METRIC)], NOW.replace(hour=14))
async with s.begin():
learned = await norms_at(s, [(src, host, METRIC), (src, part, METRIC)],
NOW.replace(hour=14))
async with s.begin():
await _report(s, src, host, at, 90.0)
await _report(s, src, part, at, 90.0)
levels = await levels_now(s, at)
async with s.begin():
levels = await levels_now(s, at)
async with s.begin():
await detect(s, at)
opened = list((await s.execute(select(MetricAnomaly.resource_name).where(
MetricAnomaly.source_module == src))).scalars())
async with s.begin():
opened = list((await s.execute(select(MetricAnomaly.resource_name).where(
MetricAnomaly.source_module == src))).scalars())
return learned, levels, opened
learned, levels, opened = asyncio.run(_go())