Skip to content

Add property-based tests for label normalisation idempotency #7

@coderabbitai

Description

@coderabbitai

Background

PR #6 (#6) introduced create_labels/sync.py, which normalises remote GitHub label fields (colour uppercasing, description trimming) before comparing them with the desired LabelSpec. Normalisation invariants are enforced in LabelSpec.__post_init__ but no property-based tests verify that sync_labels returns "unchanged" for the full space of denormalised GitHub responses that are semantically equivalent after normalisation.

Required work

  • Add hypothesis to the [dependency-groups].dev section of pyproject.toml.
  • Add property tests in tests/test_sync.py (or a new tests/test_sync_properties.py) that use @given strategies to generate:
    • arbitrary lowercase/mixed-case six-character hex colour strings (with and without a leading #);
    • arbitrary description strings with leading/trailing whitespace.
  • Assert that sync_labels returns LabelSyncResult(name, "unchanged") and makes no update calls whenever the normalised remote values match the configured LabelSpec.

Acceptance criteria

  • hypothesis is declared as a dev dependency.
  • At least one @given-decorated test verifies colour-case idempotency.
  • At least one @given-decorated test verifies description-whitespace idempotency.
  • make test passes with the new property tests included.

Raised by @leynos following review of PR #6.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions