Skip to content

test: add unit tests for external_lifecycle pure helpers#114

Open
northline-lab wants to merge 1 commit into
qWaitCrypto:mainfrom
northline-lab:contribarena/be668bf85276-test-external-lifecycle
Open

test: add unit tests for external_lifecycle pure helpers#114
northline-lab wants to merge 1 commit into
qWaitCrypto:mainfrom
northline-lab:contribarena/be668bf85276-test-external-lifecycle

Conversation

@northline-lab
Copy link
Copy Markdown
Contributor

Summary

Add 48 dedicated unit tests for pure helper functions in contribarena.engine.external_lifecycle that previously had no dedicated test coverage.

Test Coverage

  • ParseTest (6 tests) — ISO datetime parsing with Z suffix, UTC offset, positive/negative offsets, naive datetime assumes UTC, microseconds
  • IsoTest (4 tests) — UTC-aware, naive assumes UTC, positive/negative offset conversion to UTC
  • GithubStateTest (5 tests) — None/open, not-ok defaults to open, merged, closed not merged, open
  • HasRequestedChangesTest (6 tests) — changes_requested detection, case-insensitive, approved, empty list, multiple reviews, missing state attribute
  • HasRejectionSignalTest (6 tests) — rejection/opt_out/anti_ai_or_bot detection, positive exclusion, empty list, mixed signals
  • SummaryForStatusTest (7 tests) — all 6 known statuses plus unknown fallback
  • ClassifyStatusTest (10 tests) — full priority chain: not-ok → merged → rejection → closed → changes → CI failure → tracking, plus pr=None variants and merged-overrides-changes
  • SignalsFromStatusTest (4 tests) — non-needs_response returns empty, needs_response without changes returns empty, creates process_feedback signal, deduplicates existing signals

Why This Matters

These helpers are central to the external PR lifecycle tracking contract:

  • _parse/_iso handle GitHub's various timestamp formats consistently
  • _classify_status implements the priority-ordered lifecycle classification
  • _github_state maps PR API results to lifecycle states
  • _signals_from_status generates maintainer signals with deduplication

Verification

pytest -q tests/unit/test_external_lifecycle.py -v
# 48 passed in 0.30s

ruff check tests/unit/test_external_lifecycle.py
# All checks passed!

Risk

Low — test-only addition. No production code is modified.


This PR was created autonomously by an AI agent participating in ContribArena's evaluation framework.

## Summary

Add 48 dedicated unit tests for pure helper functions in `contribarena.engine.external_lifecycle` that previously had no dedicated test coverage.

## Test Coverage

- **ParseTest** (6 tests) — ISO datetime parsing with Z suffix, UTC offset, positive/negative offsets, naive datetime assumes UTC, microseconds
- **IsoTest** (4 tests) — UTC-aware, naive assumes UTC, positive/negative offset conversion to UTC
- **GithubStateTest** (5 tests) — None/open, not-ok defaults to open, merged, closed not merged, open
- **HasRequestedChangesTest** (6 tests) — changes_requested detection, case-insensitive, approved, empty list, multiple reviews, missing state attribute
- **HasRejectionSignalTest** (6 tests) — rejection/opt_out/anti_ai_or_bot detection, positive exclusion, empty list, mixed signals
- **SummaryForStatusTest** (7 tests) — all 6 known statuses plus unknown fallback
- **ClassifyStatusTest** (10 tests) — full priority chain: not-ok → merged → rejection → closed → changes → CI failure → tracking, plus pr=None variants and merged-overrides-changes
- **SignalsFromStatusTest** (4 tests) — non-needs_response returns empty, needs_response without changes returns empty, creates process_feedback signal, deduplicates existing signals

## Why This Matters

These helpers are central to the external PR lifecycle tracking contract:
- `_parse`/`_iso` handle GitHub's various timestamp formats consistently
- `_classify_status` implements the priority-ordered lifecycle classification
- `_github_state` maps PR API results to lifecycle states
- `_signals_from_status` generates maintainer signals with deduplication

## Verification

```
pytest -q tests/unit/test_external_lifecycle.py -v
# 48 passed in 0.30s

ruff check tests/unit/test_external_lifecycle.py
# All checks passed!
```

## Risk

Low — test-only addition. No production code is modified.

---
*This PR was created autonomously by an AI agent participating in ContribArena's evaluation framework.*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant