50 lines
1.8 KiB
Python
50 lines
1.8 KiB
Python
"""Tests for backlog_triage.py categorization logic."""
|
|
import pytest
|
|
from scripts.backlog_triage import categorize_issues
|
|
|
|
|
|
def test_unassigned_issues():
|
|
issues = [
|
|
{"number": 1, "title": "Fix bug", "assignee": None, "labels": []},
|
|
{"number": 2, "title": "Feature", "assignee": {"login": "user"}, "labels": []},
|
|
]
|
|
result = categorize_issues(issues)
|
|
assert len(result["unassigned"]) == 1
|
|
assert result["unassigned"][0]["number"] == 1
|
|
|
|
|
|
def test_no_labels():
|
|
issues = [
|
|
{"number": 1, "title": "No label", "assignee": None, "labels": []},
|
|
{"number": 2, "title": "Has label", "assignee": None, "labels": [{"name": "bug"}]},
|
|
]
|
|
result = categorize_issues(issues)
|
|
assert len(result["no_labels"]) == 1
|
|
assert result["no_labels"][0]["number"] == 1
|
|
|
|
|
|
def test_batch_pipeline():
|
|
issues = [
|
|
{"number": 1, "title": "batch-pipeline: update genome", "assignee": None, "labels": []},
|
|
{"number": 2, "title": "Normal issue", "assignee": None, "labels": [{"name": "batch-pipeline"}]},
|
|
{"number": 3, "title": "Other", "assignee": None, "labels": []},
|
|
]
|
|
result = categorize_issues(issues)
|
|
assert len(result["batch_pipeline"]) == 2
|
|
numbers = {i["number"] for i in result["batch_pipeline"]}
|
|
assert numbers == {1, 2}
|
|
|
|
|
|
def test_skips_pull_requests():
|
|
issues = [
|
|
{"number": 1, "title": "Issue", "assignee": None, "labels": []},
|
|
{"number": 2, "title": "PR", "assignee": None, "labels": [], "pull_request": {}},
|
|
]
|
|
result = categorize_issues(issues)
|
|
# Only issue #1 should be counted, PR #2 excluded
|
|
assert len(result["unassigned"]) == 1
|
|
assert result["unassigned"][0]["number"] == 1
|
|
assert len(result["no_labels"]) == 1
|
|
assert result["no_labels"][0]["number"] == 1
|
|
assert len(result["batch_pipeline"]) == 0
|