Skip to content

test: add unit test for build_sparkline_data() polarity logic with lower-is-better metrics #355

@decko

Description

@decko

Finding

File: tests/test_report_html.py:4512
Source ticket: RAKI-305

test_rework_cycles_lower_is_better_direction_is_up is a tautological test — it constructs a fixture with direction='up' at line 4409 and then asserts direction=='up'. This validates only the fixture's self-consistency, not the production build_sparkline_data() polarity logic. While acceptable as a regression guard against fixture drift, it does not exercise the real production code path.

Suggested Fix

Add a dedicated unit test in test_sparkline.py that:

  1. Calls build_sparkline_data() with metric_polarity={"rework_cycles": False} and decreasing values.
  2. Asserts the returned direction="up" (i.e., lower values are better → trend going down is reported as improvement → direction up).

This would test the production code path directly rather than fixture self-consistency.

References

  • PR: fix inverted SparklineData direction semantics for lower-is-better metrics in _make_report_with_sparklines (RAKI-305)

Metadata

Metadata

Assignees

No one assigned

    Labels

    triage-neededNeeds investigation or decision

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions