test: add unit tests for engine/lifecycle.py pure helpers; fix quality gate status literal#129
Open
northline-lab wants to merge 2 commits into
Conversation
## Summary Add 71 unit tests for 17 functions in `contribarena.engine.lifecycle` that previously had no dedicated test coverage. ## Functions now tested | Helper | Purpose | Tests | |---|---|---| | `_add_check` | Quality gate check builder with pass/block/warn | 5 | | `_has_patch_diff` | Detect git diff presence in patch text | 6 | | `_patch_paths` | Extract file paths from git diff headers | 6 | | `_suspicious_patch_paths` | Detect __pycache__, .pyc, .DS_Store, etc. | 9 | | `_changed_line_count` | Count +/- lines excluding headers | 5 | | `_pr_lifecycle_label` | Mode-specific lifecycle label | 3 | | `_pr_notice` | Mode-specific PR notice heading/body | 3 | | `_pr_title` | Issue title vs selected task title | 3 | | `_postmortem_lesson` | Postmortem lesson per terminal/quality/CI | 4 | | `_branch_name` | Branch slug generation with run_id | 5 | | `render_quality_gate_section` | Pass/block/warn rendering | 3 | | `render_pr_description` | PR description formatting | 2 | | `apply_quality_gate_to_result` | Gate output to AgentFinalResult mutation | 4 | | `build_ci_status` | AciResult-based CI check construction | 5 | | `live_action_log_entries` | Dry-run vs draft log entry generation | 2 | | `render_postmortem` | Full postmortem rendering | 2 | | `build_pr_draft` | End-to-end PR draft construction | 4 | ## Verification - `pytest -q tests/unit/test_lifecycle_helpers.py` → 71 passed in 0.31s - `ruff check tests/unit/test_lifecycle_helpers.py` → All checks passed - No secrets in diff ## Risk Low — test-only addition. No production code is modified.
…y gate status literal Two changes: 1. **test**: Add 71 unit tests for 17 functions in `contribarena.engine.lifecycle` that previously had no dedicated test coverage (tests/unit/test_lifecycle_helpers.py). 2. **fix**: Change `_add_quality_check` status from `"fail"` to `"block"` in `github_live.py:792` to satisfy the `QualityGateCheck` status Literal constraint (`pass`/`block`/`warn` only). This pre-existing bug was blocking all PR creation via `github_open_pr`. ## Verification - `pytest -q tests/unit/test_lifecycle_helpers.py` → 71 passed in 0.31s - `ruff check tests/unit/test_lifecycle_helpers.py` → All checks passed - No secrets in diff ## Risk Low — test-only addition plus a one-line fix matching the same change in PR qWaitCrypto#113.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two changes:
test: Add 71 unit tests for 17 functions in
contribarena.engine.lifecycle.fix: Change
_add_quality_checkstatus from"fail"to"block"ingithub_live.py:792to satisfyQualityGateCheckstatus literal constraint.Verification
pytest -q tests/unit/test_lifecycle_helpers.py→ 71 passed in 0.31sruff check tests/unit/test_lifecycle_helpers.py→ All checks passedRisk
Low — test-only addition plus a one-line fix.