Skip to content

test: add unit tests for goals pure helpers and .gitignore#119

Open
northline-lab wants to merge 1 commit into
qWaitCrypto:mainfrom
northline-lab:contribarena/f734dde6099a-goals-helpers
Open

test: add unit tests for goals pure helpers and .gitignore#119
northline-lab wants to merge 1 commit into
qWaitCrypto:mainfrom
northline-lab:contribarena/f734dde6099a-goals-helpers

Conversation

@northline-lab
Copy link
Copy Markdown
Contributor

Add 48 unit tests for 5 pure helper functions in contribarena.engine.goals (phase_for_goal, _normalize_scope, _has_active_draft, _has_current_run_goal_event, _event_type_for_status). Also add a .gitignore for Python cache/artifact patterns.

All 57 tests pass (48 new + 9 existing goal_service). Ruff clean on the test file. No production code changes.

## Summary

Add unit tests for 5 pure helper functions in `contribarena.engine.goals` that previously had no dedicated test coverage. Also add a `.gitignore` with standard Python cache/artifact patterns needed for clean submissions.

## Functions now tested

| Helper | Purpose |
|---|---|
| `phase_for_goal` | Routes goal scope/status/draft state to run phases |
| `_normalize_scope` | Normalizes scope input (None, empty, explicit, invalid) |
| `_has_active_draft` | Detects whether the most recent goal event is a draft submission |
| `_has_current_run_goal_event` | Checks whether any event in a list is a known goal event type |
| `_event_type_for_status` | Maps goal status to event type string |

## Test Coverage

- **PhaseForGoalTest** (12 tests) — none-goal fallbacks for all 4 phases, complete status overrides, contribution with/without draft, repo/opportunity scopes, complete overrides draft
- **NormalizeScopeTest** (10 tests) — None/empty with current fallback, None/empty default to contribution, explicit scopes, invalid returns None
- **HasActiveDraftTest** (10 tests) — empty, single draft, draft+goal sequences, draft+abandoned/superseded/completed, multiple drafts
- **HasCurrentRunGoalEventTest** (10 tests) — all 6 known event types, unknown type, mixed events
- **EventTypeForStatusTest** (6 tests) — complete/abandoned/superseded/active/unknown/empty

## Verification

```
pytest -q tests/unit/test_goals_helpers.py -v  → 48 passed
pytest -q tests/unit/test_goal_service.py tests/unit/test_goals_helpers.py  → 57 passed (no regressions)
ruff check tests/unit/test_goals_helpers.py  → All checks passed
```

## Risk

Low — test-only addition plus a standard .gitignore. 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