Skip to content

test: move fine-grained Python API shim coverage into Rust #88

Closed

Description

@zackees

Follow-up to #72 and PR #77. Part of the broader Rust migration in #14.

Context

After the app/orchestration migration, the Python package is now mostly a public compatibility/API shim over fastled._native. The remaining Python unit coverage in tests/unit/test_python_api.py currently checks both:

  • high-level Python package contract, such as from fastled import ...
  • fine-grained behavior of PyO3-owned types and helpers, such as BuildMode, BuildRequest, BuildArtifacts, CompileResult, BuildService.detect_strategy, is_in_order_match, and string_diff

That second group now lives in Rust, so testing those internals from pytest keeps unnecessary Python surface area in the test suite.

Proposal

Move fine-grained native API behavior tests into Rust, primarily under crates/fastled-py, while keeping a small high-level Python smoke test for the public Python package contract.

The intended split:

  • Rust tests cover PyO3/native implementation details.
  • Python tests cover public import/export compatibility and a minimal end-to-end API smoke path.
  • Python hook tests stay Python because they exercise Python hook code, not the FastLED native API shim.

Suggested tasks

  • Add Rust tests in crates/fastled-py for PyBuildMode parsing/display behavior.
  • Add Rust tests for PyBuildRequest defaults, especially output_dir == sketch_dir / fastled_js.
  • Add Rust tests for PyBuildArtifacts mapping/dict-like behavior.
  • Add Rust tests for PyCompileResult truthiness and dictionary serialization.
  • Add Rust tests for PyBuildService::detect_strategy_inner, including cold default behavior and any cheap non-build strategy transitions.
  • Keep existing Rust string matching tests, and expand them only if needed to replace assertions currently made from test_python_api.py.
  • Shrink tests/unit/test_python_api.py to high-level Python API coverage only: package imports, exported names, and a minimal smoke check that native objects are reachable through fastled.
  • Leave tests/unit/test_tool_guard_hook.py in Python.
  • Update ./test only if needed; it should continue to run cargo test --workspace before pytest.

Acceptance criteria

  • Fine-grained behavior currently asserted in tests/unit/test_python_api.py is covered by Rust tests.
  • Python tests still verify the public fastled package API remains importable and exposes the expected native-backed symbols.
  • Python tests no longer duplicate implementation-detail coverage for PyO3-owned DTOs/helpers.
  • ./test passes.
  • The test split documents the intended boundary: Rust owns internals; Python owns public compatibility smoke coverage.

Related issues

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions