metric-test

Author and validate YAML fixture and pytest specs for data-path metric tests.

10|9|Updated May 22, 2026
One-click install
npx skills add https://github.com/constructorfabric/insight --skill metric-test-constructorfabric
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: metric-test
Source: https://github.com/constructorfabric/insight/tree/main/.claude/skills/metric-test
Command: npx skills add https://github.com/constructorfabric/insight --skill metric-test-constructorfabric

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing end-to-end tests for analytics metrics requires seeding bronze warehouse data, running dbt silver and gold models, and asserting API responses — a complex, error-prone process. This Skill scaffolds and validates the metric spec pair (a <name>.test.yaml fixture plus a test_<name>.py module) so the full bronze → silver → gold → analytics path is tested against a compose test-stand instance. ## Core Features & Use Cases - Spec scaffolding: Create a new <class>/<name>.test.yaml fixture with the required schemas and templates via /metric-test create <name> --metric <key> --tables <t1,t2>. - Offline validation: Resolve $ref references, schema-validate bronze records, and lint the pytest module without needing a running stand via /metric-test validate <path>. - Assertion guidance: Covers the assertion helpers (row/equals/contains, one/some over a view, approx), account bindings, identity aliases, duplicate-row dedup cases, and date-window boundary test design. - Use Case: When asked to "write a test for the emails-sent metric", the Skill produces the fixture seeding M365 bronze rows (including a re-sync duplicate) and a pytest module asserting collab.emails_sent period and peer values through POST /v1/metric-results. ## Quick Start Ask the assistant to write a test for a specific metric, for example: "Create a metric test for collab.emails_sent seeding m365 email activity rows."

Frequently Asked Questions about metric-test

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write a test for an analytics metric?

Create a `<class>/<name>.test.yaml` fixture that seeds bronze tables with `$ref`-based records, plus a `test_<name>.py` module that calls POST /v1/metric-results and asserts rows with `r.row(key, view).equals(...)`. The `/metric-test create` command scaffolds both files.

How do I validate a metric test fixture without running the test stand?

Run the fixture loader with substitutions for tenant and supervisor placeholders, or use `/metric-test validate <path>`. It checks that every `$ref` resolves, each padded bronze record passes its JSON schema, and all placeholders are ones the run supplies.

How does the YAML fixture handle duplicate bronze records?

Two identical rows in the fixture simulate a real Airbyte re-sync duplicate, and the test asserts the metric dedups them rather than double-counting. After `$ref` resolution each row is padded to the full schema and validated with additionalProperties set to false.

Why does a seeded person drop out of team or department metrics?

Team attribution is a LEFT JOIN on lowercased email, so the person's M365 userPrincipalName must match their BambooHR workEmail case-insensitively. A mismatch resolves org_unit_id to NULL and silently excludes the person from the median and range computation.

What are the limitations of running the data-path suite?

The suite requires its own compose instance raised with `minimal`, since a stand seeded through silver is refused. Trees must be passed via `--tree=`, and linting with ruff must not run concurrently because the shared tests venv holds one dependency group at a time.