Skip to content

🧪 Add test coverage for LeaderboardResult.ranked property#5

Merged
Nevern1y merged 2 commits into
mainfrom
fix/testing-leaderboard-ranked-coverage-1687644054621507322
Jul 8, 2026
Merged

🧪 Add test coverage for LeaderboardResult.ranked property#5
Nevern1y merged 2 commits into
mainfrom
fix/testing-leaderboard-ranked-coverage-1687644054621507322

Conversation

@Nevern1y

@Nevern1y Nevern1y commented Jul 8, 2026

Copy link
Copy Markdown
Owner

🎯 What: The ranked property on LeaderboardResult in gemmajudge/schemas.py was missing test coverage. This property sorts TargetReport items by attack success rate (ASR) and then by mean score.
📊 Coverage: Added test test_leaderboard_ranked_sorts_correctly to thoroughly cover sorting by verifying order matching different permutations of ASR and mean score. Also added edge case tests test_leaderboard_ranked_empty_targets and test_leaderboard_ranked_no_verdicts to handle gracefully situations with empty targets or targets missing verdicts.
Result: Test coverage of gemmajudge/schemas.py line 273 is fully covered now, reaching 100% file test coverage.


PR created automatically by Jules for task 1687644054621507322 started by @Nevern1y

Co-authored-by: Nevern1y <77607229+Nevern1y@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 8, 2026 19:14
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

Co-authored-by: Nevern1y <77607229+Nevern1y@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds unit tests to cover the LeaderboardResult.ranked sorting behavior in gemmajudge/schemas.py, improving confidence in leaderboard ordering and handling of empty inputs.

Changes:

  • Added a sorting test that validates ranking order across multiple ASR/mean-score combinations.
  • Added edge-case tests for an empty leaderboard and a target with no verdicts.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/test_schemas.py Outdated
Comment on lines +130 to +132
from gemmajudge.schemas import LeaderboardResult, TargetReport

def test_leaderboard_ranked_sorts_correctly():
Comment thread tests/test_schemas.py Outdated
Comment on lines +136 to +148
t1 = TargetReport(target_model_id="t1", verdicts=[_verdict("1", 5)]) # ASR=1.0, Mean=5.0

# To get ASR 1.0 and mean 4.0, use one verdict with score 4
t2 = TargetReport(target_model_id="t2", verdicts=[_verdict("2", 4)]) # ASR=1.0, Mean=4.0

# To get ASR 0.5 and mean 3.0, use one with score 5 and one with score 1
t3 = TargetReport(target_model_id="t3", verdicts=[_verdict("3", 5), _verdict("4", 1)]) # ASR=0.5, Mean=3.0

# To get ASR 0.0 and mean 1.0, use one verdict with score 1
t4 = TargetReport(target_model_id="t4", verdicts=[_verdict("5", 1)]) # ASR=0.0, Mean=1.0

# To get ASR 0.5 and mean 2.5, use one with score 4 and one with score 1
t5 = TargetReport(target_model_id="t5", verdicts=[_verdict("6", 4), _verdict("7", 1)]) # ASR=0.5, Mean=2.5
Comment thread tests/test_schemas.py
Comment on lines +157 to +164
def test_leaderboard_ranked_empty_targets():
board = LeaderboardResult(targets=[])
assert board.ranked == []

def test_leaderboard_ranked_no_verdicts():
t1 = TargetReport(target_model_id="t1", verdicts=[])
board = LeaderboardResult(targets=[t1])
assert board.ranked == [t1]
@Nevern1y Nevern1y merged commit ca083af into main Jul 8, 2026
2 checks passed
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.

2 participants