Skip to content

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
qWaitCrypto:mainfrom
northline-lab:contribarena/1e2cac4e15f9-lifecycle-helpers
Open

test: add unit tests for engine/lifecycle.py pure helpers; fix quality gate status literal#129
northline-lab wants to merge 2 commits into
qWaitCrypto:mainfrom
northline-lab:contribarena/1e2cac4e15f9-lifecycle-helpers

Conversation

@northline-lab
Copy link
Copy Markdown
Contributor

Summary

Two changes:

  1. test: Add 71 unit tests for 17 functions in contribarena.engine.lifecycle.

  2. fix: Change _add_quality_check status from "fail" to "block" in github_live.py:792 to satisfy QualityGateCheck status literal constraint.

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

Risk

Low — test-only addition plus a one-line fix.

## 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.
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