Skip to content

test: add unit tests for repo_prs pure helper functions#123

Open
northline-lab wants to merge 1 commit into
qWaitCrypto:mainfrom
northline-lab:contribarena/1a96ba154066-repo-prs-helpers
Open

test: add unit tests for repo_prs pure helper functions#123
northline-lab wants to merge 1 commit into
qWaitCrypto:mainfrom
northline-lab:contribarena/1a96ba154066-repo-prs-helpers

Conversation

@northline-lab
Copy link
Copy Markdown
Contributor

Summary

Add 45 unit tests for 6 pure helper functions in contribarena.tools.repo_prs that previously had no dedicated test coverage.

Functions now tested

Helper Purpose
_labels Extract label names from mixed list formats (dict with "name" key or plain strings)
_linked_issues Extract issue numbers from closing-issues references
_assignees Extract login names from assignee list
_optional_str Convert truthy values to string, falsy to None
_from_gh Parse PullRequestCandidate from GitHub GraphQL-style response
_from_rest Parse PullRequestCandidate from GitHub REST API response

Test Coverage

  • LabelsTest (10 tests) — empty list, None input, non-list input, dict items with name, string items, mixed formats, empty/None name filtered, dict without name key
  • LinkedIssuesTest (9 tests) — empty list, None input, non-list input, dict items with number, string number converted, missing/zero/None number filtered, non-dict skipped
  • AssigneesTest (8 tests) — empty assignees, no key, not list, single/multiple assignees, empty/None login returns empty string, non-dict skipped
  • OptionalStrTest (6 tests) — None returns None, empty string returns None, string value, non-string converted, zero/False returns None
  • FromGhTest (6 tests) — minimal item defaults, full item with all fields, author not dict, author None, draft true, number as string
  • FromRestTest (6 tests) — minimal item defaults, full item with all fields, user not dict, user None, draft true, labels always empty

No production code is modified.

Verification

  • pytest -q tests/unit/test_repo_prs_helpers.py → 45 passed in 0.33s
  • ruff check tests/unit/test_repo_prs_helpers.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 45 unit tests for 6 pure helper functions in `contribarena.tools.repo_prs` that previously had no dedicated test coverage.

## Functions now tested

| Helper | Purpose |
|---|---|
| `_labels` | Extract label names from mixed list formats (dict with "name" key or plain strings) |
| `_linked_issues` | Extract issue numbers from closing-issues references |
| `_assignees` | Extract login names from assignee list |
| `_optional_str` | Convert truthy values to string, falsy to None |
| `_from_gh` | Parse PullRequestCandidate from GitHub GraphQL-style response |
| `_from_rest` | Parse PullRequestCandidate from GitHub REST API response |

## Test Coverage

- **LabelsTest** (10 tests) — empty list, None input, non-list input, dict items with name, string items, mixed formats, empty/None name filtered, dict without name key
- **LinkedIssuesTest** (9 tests) — empty list, None input, non-list input, dict items with number, string number converted, missing/zero/None number filtered, non-dict skipped
- **AssigneesTest** (8 tests) — empty assignees, no key, not list, single/multiple assignees, empty/None login returns empty string, non-dict skipped
- **OptionalStrTest** (6 tests) — None returns None, empty string returns None, string value, non-string converted, zero/False returns None
- **FromGhTest** (6 tests) — minimal item defaults, full item with all fields, author not dict, author None, draft true, number as string
- **FromRestTest** (6 tests) — minimal item defaults, full item with all fields, user not dict, user None, draft true, labels always empty

No production code is modified.

## Verification

- `pytest -q tests/unit/test_repo_prs_helpers.py` → 45 passed in 0.33s
- `ruff check tests/unit/test_repo_prs_helpers.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