Skip to content

[T-017] Test infrastructure: Hypothesis profiles, factories, fakes package, Testcontainers Postgres fixture #25

Closed

Description

@CodewithJha

Task T-017 · Milestone M1 — Foundation · Size S · Priority P0 · Epic #1

Implements NFR-MNT-001

Branch test/t-017-test-infrastructure-hypothesis-profiles-factories — one task = one branch = one PR (doc 32 §6)

Summary

Provide the shared test scaffolding of doc 18 §5 so every later task writes tests the same way: Hypothesis profiles (ci=200, nightly=2000 examples), domain object factories, a tests/fakes/ package and a session-scoped PostgreSQL 17 Testcontainers fixture.

Context / motivation

Without shared fixtures each agent invents its own, producing duplicated and flaky tests. A single Postgres fixture with per-test transactional isolation keeps integration tests fast (< 6 min budget, doc 18 §2).

Scope

In scope

  • backend/tests/conftest.py: Hypothesis profiles via settings.register_profile, selected by HYPOTHESIS_PROFILE env.
  • backend/tests/factories.py: builders for Scenario, Observation, Trace (straight-line synthetic), OracleResult, RunOutcome.
  • backend/tests/fakes/__init__.py (empty package, later filled by port tasks).
  • backend/tests/integration/conftest.py: postgres_url session fixture using testcontainers.postgres.PostgresContainer('postgres:17'), skipped with a clear reason when Docker is unavailable; ROBOPROBE_TEST_DATABASE_URL override for CI service containers.
  • pytest-xdist compatible (no shared mutable state).

Implementation guidance

  • Factories are plain functions with keyword overrides (no factory-boy dependency). Make the synthetic trace builder accept n, dt, and per-column overrides so oracle tests can craft edge cases.
  • Standards: respect the layering contracts (doc 16 §2) and conventions in doc 34; no hard-coded tunables — thresholds/defaults come from typed settings (doc 27); no magic numbers (ruff PLR2004); public APIs typed (mypy strict) and documented.

Acceptance criteria

  • pytest -m integration spins up Postgres 17 locally and in CI.
  • Profiles switch with HYPOTHESIS_PROFILE=nightly.
  • Factories produce valid frozen models (validated by tests).
  • Tests listed below added and green in CI; coverage of new code meets the gate in doc 18 §3.
  • Docs, config reference and CHANGELOG Unreleased updated where behaviour, keys or interfaces changed.
  • Definition of Done (doc 32 §3) satisfied.

Tests required

  • Self-tests for factories and the Postgres fixture (SELECT version() returns 17.x).

Dependencies

Blocked by: #12 (T-001), #15 (T-002a)

Blocks: #28 (T-006a), #59 (T-010a), #69 (T-019)

Parallelization notes

Files / paths owned by this task — avoid editing other paths; shared files (pyproject.toml entry points, cli/main.py, api/routers/__init__.py, router.tsx, docker/compose.yaml, ci.yml) are append-only:

  • backend/tests/conftest.py
  • backend/tests/factories.py
  • backend/tests/fakes/__init__.py
  • backend/tests/integration/conftest.py

Owns shared test helpers; later tasks add new factories in their own test modules or append to factories.py (small, append-only).

Definition of Done

Per doc 32 §3 and AGENTS.md §5: lint, format, mypy strict and import-linter green; tests added and passing; docs updated; PR template completed with Closes #<this issue>; Conventional Commit messages referencing T-017 (doc 16 §6); commits authored only by the repository owner identity (AGENTS.md §4); CI green; reviewer checklist (doc 32 §5.1) satisfied.

References

Design docs: doc 18 §2 · doc 18 §5 · doc 18 §3

Requirements: NFR-MNT-001 (traceability: doc 28)

External:

Activity

  1. added this to the M1 — Foundation milestone on Nov 19, 2026
  2. added
    type:testTest suites and test infrastructure
    area:coreDomain core, plugin registry, shared types
    area:ciCI/CD workflows
    priority:P0Critical path / blocks others
    taskChild task of a milestone epic
    on Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:ciCI/CD workflowsarea:coreDomain core, plugin registry, shared typesmilestone:M1M1 — Foundationpriority:P0Critical path / blocks otherssize:S<= 1 daytaskChild task of a milestone epictype:testTest suites and test infrastructure

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions