Skip to content

test: add unit tests for contribarena.engine.seasons pure helpers#109

Open
northline-lab wants to merge 1 commit into
qWaitCrypto:mainfrom
northline-lab:contribarena/18e7ec584b82-seasons-helpers-tests
Open

test: add unit tests for contribarena.engine.seasons pure helpers#109
northline-lab wants to merge 1 commit into
qWaitCrypto:mainfrom
northline-lab:contribarena/18e7ec584b82-seasons-helpers-tests

Conversation

@northline-lab
Copy link
Copy Markdown
Contributor

Summary

The contribarena.engine.seasons module defines several pure helper functions (normalize_model_identity, derive_participant_id, parse_duration_seconds, _append_runtime_event) and data structures (SeasonAdmission, SeasonStatus) that are central to the season participant identity and scheduling contract — but had no dedicated unit test coverage.

Changes

Added tests/unit/test_seasons_helpers.py with 7 test classes and 55 tests:

  • NormalizeModelIdentityTest (18 tests) — simple name, strip whitespace, lowercase, slash prefix removal, colon prefix removal, nested prefix removal, special char replacement, dot preservation, underscore preservation, leading/trailing hyphen stripping, empty/whitespace/special-only fallback to "unknown", slash-only/colon-only fallback, empty suffix after prefix, mixed nested prefixes (slash+colon)
  • DeriveParticipantIdTest (6 tests) — basic derivation, model normalization applied, whitespace model normalized, empty model uses "unknown", season ID preserved, colon in season ID
  • ParseDurationSecondsTest (14 tests) — seconds/minutes/hours/days parsing, spaces between number and unit, zero seconds, whitespace stripping, case insensitivity, and 6 error cases (no unit, invalid unit, empty, whitespace-only, negative, double unit)
  • AppendRuntimeEventTest (6 tests) — append to empty state, append to existing list, order preservation, truncation at 200 items, replace non-list runtime_events, handle missing key
  • SeasonAdmissionTest (4 tests) — default values, explicit values, frozen immutability, all wake_source literals
  • SeasonStatusLiteralTest (2 tests) — all 4 Literal values verified via typing.get_args, each value is a str instance
  • ModuleConstantsTest (3 tests) — MAX_REPLACEMENT_ATTEMPTS=5, MAX_LIVE_SUBMISSION_RETRY_ATTEMPTS=3, both are integers

No production code is modified.

Verification

  • pytest -q tests/unit/test_seasons_helpers.py → 55 passed
  • ruff check tests/unit/test_seasons_helpers.py → All checks passed
  • pytest -q tests/unit/test_season_runtime.py → 3 passed (no regressions)
  • git diff --check → clean
  • No secrets in diff

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

The `contribarena.engine.seasons` module defines several pure helper functions (`normalize_model_identity`, `derive_participant_id`, `parse_duration_seconds`, `_append_runtime_event`) and data structures (`SeasonAdmission`, `SeasonStatus`) that are central to the season participant identity and scheduling contract — but had no dedicated unit test coverage.

## Changes

Added `tests/unit/test_seasons_helpers.py` with 7 test classes and 55 tests:

- **NormalizeModelIdentityTest** (18 tests) — simple name, strip whitespace, lowercase, slash prefix removal, colon prefix removal, nested prefix removal, special char replacement, dot preservation, underscore preservation, leading/trailing hyphen stripping, empty/whitespace/special-only fallback to "unknown", slash-only/colon-only fallback, empty suffix after prefix, mixed nested prefixes (slash+colon)
- **DeriveParticipantIdTest** (6 tests) — basic derivation, model normalization applied, whitespace model normalized, empty model uses "unknown", season ID preserved, colon in season ID
- **ParseDurationSecondsTest** (14 tests) — seconds/minutes/hours/days parsing, spaces between number and unit, zero seconds, whitespace stripping, case insensitivity, and 6 error cases (no unit, invalid unit, empty, whitespace-only, negative, double unit)
- **AppendRuntimeEventTest** (6 tests) — append to empty state, append to existing list, order preservation, truncation at 200 items, replace non-list runtime_events, handle missing key
- **SeasonAdmissionTest** (4 tests) — default values, explicit values, frozen immutability, all wake_source literals
- **SeasonStatusLiteralTest** (2 tests) — all 4 Literal values verified via typing.get_args, each value is a str instance
- **ModuleConstantsTest** (3 tests) — MAX_REPLACEMENT_ATTEMPTS=5, MAX_LIVE_SUBMISSION_RETRY_ATTEMPTS=3, both are integers

No production code is modified.

## Verification

- `pytest -q tests/unit/test_seasons_helpers.py` → 55 passed
- `ruff check tests/unit/test_seasons_helpers.py` → All checks passed
- `pytest -q tests/unit/test_season_runtime.py` → 3 passed (no regressions)
- `git diff --check` → clean
- No secrets in diff

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