Skip to content

test: add unit tests for repo_eligibility pure helpers#112

Open
northline-lab wants to merge 1 commit into
qWaitCrypto:mainfrom
northline-lab:contribarena/336a92e054ff-repo-eligibility-tests
Open

test: add unit tests for repo_eligibility pure helpers#112
northline-lab wants to merge 1 commit into
qWaitCrypto:mainfrom
northline-lab:contribarena/336a92e054ff-repo-eligibility-tests

Conversation

@northline-lab
Copy link
Copy Markdown
Contributor

Summary

Add 36 unit tests for four pure helper functions in contribarena.tools.repo_eligibility that previously had no dedicated test coverage.

Test Coverage

ParseGithubDatetimeTest (5 tests)

  • ISO format parsing with Z suffix and timezone offsets
  • Invalid format handling
  • UTC timezone conversion
  • Edge cases (empty strings, various formats)

LooksEnglishTest (8 tests)

  • ASCII ratio calculation and threshold behavior
  • 85% boundary conditions (exactly at, above, below)
  • Long text truncation at 2000 characters
  • Whitespace and empty string handling

ProhibitsAiOrBotsTest (10 tests)

  • All six prohibited phrase variants detected
  • Case-insensitive matching
  • Partial phrase rejection (e.g., "AI tools" doesn't trigger)
  • Empty text handling

IsExternalRecentPrTest (13 tests)

  • External contributor detection
  • Owner exclusion (case-insensitive)
  • Bot account filtering ([bot] suffix)
  • Time boundary handling (exactly at, after)
  • REST API format support (merged_at vs mergedAt)
  • Missing/invalid data handling

Why This Matters

These pure helper functions are critical for:

  • Determining repository eligibility during discovery
  • Filtering bot/owner PRs from external contribution counts
  • Detecting repositories that prohibit AI contributions
  • Parsing GitHub's various datetime formats

Having comprehensive tests ensures the eligibility checker behaves correctly across edge cases.

Verification

pytest tests/unit/test_repo_eligibility.py -v
# 36 passed

ruff check tests/unit/test_repo_eligibility.py
# All checks passed!

Changes

  • No production code changes - test file only
  • Added tests/unit/test_repo_eligibility.py with 4 test classes

## Summary

Add 36 unit tests for four pure helper functions in `contribarena.tools.repo_eligibility` that previously had no dedicated test coverage.

## Test Coverage

- **ParseGithubDatetimeTest** (5 tests): ISO format parsing, timezone conversion, edge cases
- **LooksEnglishTest** (8 tests): ASCII ratio thresholds, boundary conditions, long text handling
- **ProhibitsAiOrBotsTest** (10 tests): All prohibited phrase variants, case sensitivity, partial matches
- **IsExternalRecentPrTest** (13 tests): External PR detection, owner/bot filtering, REST API format support, time boundaries

## Verification

```
pytest tests/unit/test_repo_eligibility.py -v
# 36 passed
ruff check tests/unit/test_repo_eligibility.py
# All checks passed!
```

No production code changes.
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