Skip to Content
SDKInsights

Insights

Insights runs aggregation queries against your organization’s test results, metrics, test runs, and tests directly.

insights.py
from rhesis.sdk.entities import Insights

# Pass rate by requirement for a specific run
stats = Insights(
    entity="test_result",
    group_by=["requirement"],
    measures=["count", "passed", "failed", "pass_rate"],
    filters={"test_run_ids": ["your-run-id"]},
).get()

for row in stats.rows:
    print(f"{row['requirement']}: {row['passed']}/{row['count']} ({row['pass_rate']}%)")

# Distinct test IDs (not test_result IDs) matching a filter, e.g. for drill-down from a chart
failed_ids = Insights(entity="test_result", filters={"test_run_ids": ["your-run-id"]}).ids(outcome="fail").ids

entity selects what each row represents, group_by the dimensions to break out by, and measures what to compute. What’s valid depends on the entity:

Entitygroup_bymeasures
test_resultrequirement, requirement_id, category, category_id, topic, topic_id, test_run, status, year, monthcount, passed, failed, pass_rate
metricmetric_name, requirement_id, year, monthcount, passed, failed, pass_rate, automated_passed, automated_failed, human_review_count
test_runstatus, test_set, executor, year, monthcount, passed, failed, pass_rate
testrequirement, requirement_id, category, category_id, topic, topic_id, is_unrun, year, monthcount, unrun_count, run_count, passed, failed, pass_rate

Filters narrow which rows are aggregated, and which keys are valid depends on the entity — a key not listed for that entity returns a 400:

Entityfilters
test_resulttest_run_ids, requirement_ids, category_ids, topic_ids, status_ids, test_ids, test_type_ids, user_ids, assignee_ids, owner_ids, prompt_ids, test_set_ids, tags
metrictest_run_ids, requirement_ids, test_ids, metric_names
test_runtest_run_ids, user_ids, endpoint_ids, test_set_ids, status_names
testrequirement_ids, category_ids, topic_ids, status_ids, test_ids, test_type_ids, user_ids, assignee_ids, owner_ids, prompt_ids, test_set_ids, tags

months, start_date, and end_date bound the date range and apply to every entity.