-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
89 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import pytest | ||
|
||
from aisploit.core import BaseReport, Score | ||
from aisploit.redteam import RedTeamReport, RedTeamReportEntry | ||
|
||
|
||
@pytest.fixture | ||
def red_team_report(): | ||
return RedTeamReport(run_id="test_run") | ||
|
||
|
||
@pytest.fixture | ||
def red_team_report_entry(): | ||
return RedTeamReportEntry( | ||
attempt=1, | ||
prompt="Test prompt", | ||
response="Test response", | ||
score=Score(flagged=True, value=0.8), | ||
) | ||
|
||
|
||
def test_red_team_report_init(red_team_report): | ||
assert isinstance(red_team_report, BaseReport) | ||
assert red_team_report.run_id == "test_run" | ||
assert len(red_team_report._entries) == 0 | ||
|
||
|
||
def test_red_team_report_add_entry(red_team_report, red_team_report_entry): | ||
red_team_report.add_entry(red_team_report_entry) | ||
assert len(red_team_report._entries) == 1 | ||
assert red_team_report._entries[0] == red_team_report_entry | ||
|
||
|
||
def test_red_team_report_final_score(red_team_report, red_team_report_entry): | ||
assert red_team_report.final_score is None | ||
|
||
red_team_report.add_entry(red_team_report_entry) | ||
assert red_team_report.final_score == red_team_report_entry.score | ||
|
||
|
||
def test_red_team_report_final_response(red_team_report, red_team_report_entry): | ||
assert red_team_report.final_response is None | ||
|
||
red_team_report.add_entry(red_team_report_entry) | ||
assert red_team_report.final_response == red_team_report_entry.response |