Skip to content

Add unit tests for Observable, Tier, and Direction types#46

Merged
jc-macdonald merged 4 commits intomainfrom
test/issue-1-observable-tier-direction
Apr 9, 2026
Merged

Add unit tests for Observable, Tier, and Direction types#46
jc-macdonald merged 4 commits intomainfrom
test/issue-1-observable-tier-direction

Conversation

@jc-macdonald
Copy link
Copy Markdown
Contributor

Summary

Unit tests for the core value types in protocols.py: Tier, Direction, and Observable.

Closes #1

Changes

1. Fix pre-existing E501 in __init__.py

Module docstring exceeded 88-char line limit; split to multi-line.

2. Add uv.lock to .gitignore

uv.lock was tracked but should not be; added to .gitignore and removed from index.

3. Tests for Tier and Direction enums

  • All members present (4 tiers, 2 directions)
  • .value strings match expected identifiers
  • Lookup by value (Tier("embedded")) returns the correct singleton
  • Invalid values raise ValueError
  • Enum identity (is) holds

4. Tests for Observable frozen dataclass

  • Field access matches constructor args
  • Frozen immutability — assignment raises AttributeError
  • Structural equality (same fields → equal)
  • Inequality on name, tier, or direction differences
  • Hashable — usable in set and as dict key
  • repr includes all field values
  • Duplicate names with different tiers are distinct objects

Stats

  • 19 new tests in tests/test_protocols.py
  • Coverage: 40% → 55.73%
  • just ci passes (format, lint, mypy strict, coverage)

Test enum membership, values, identity, and invalid-value errors for
Tier and Direction.  Test Observable field access, frozen immutability,
equality, hashing (set/dict usage), repr, and edge case where
duplicate names with different tiers are distinct.
@jc-macdonald jc-macdonald self-assigned this Apr 9, 2026
Python 3.11 is incompatible with requires-python >= 3.12.
Coverage threshold was 80% in CI but 40% in justfile; align to 40%.
@jc-macdonald jc-macdonald merged commit 1375ebf into main Apr 9, 2026
3 checks passed
@jc-macdonald jc-macdonald deleted the test/issue-1-observable-tier-direction branch April 9, 2026 17:31
@jc-macdonald jc-macdonald added test Test coverage improvement protocols protocols.py module labels Apr 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

protocols protocols.py module test Test coverage improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unit tests for Observable/Tier/Direction dataclasses

1 participant