Skip to content

FEAT: Add partner integration tests for azure-ai-evaluation red team …#1533

Open
slister1001 wants to merge 4 commits intomicrosoft:mainfrom
slister1001:partner-integration-tests
Open

FEAT: Add partner integration tests for azure-ai-evaluation red team …#1533
slister1001 wants to merge 4 commits intomicrosoft:mainfrom
slister1001:partner-integration-tests

Conversation

@slister1001
Copy link
Copy Markdown
Contributor

…module

Add tests/partner_integration/azure_ai_evaluation/ with contract tests validating PyRIT API stability for the azure-ai-evaluation red team module, which depends on 45+ PyRIT imports across 14 files.

Test coverage includes:

  • PromptChatTarget interface contract (extended by 4 SDK classes)
  • CentralMemory/SQLiteMemory lifecycle (used in RedTeam.init)
  • Data models: Message, MessagePiece, Score, seed models, AttackResult
  • PromptConverter base + 19 specific converters importability
  • Scorer/TrueFalseScorer interface (extended by RAIServiceScorer)
  • Foundry scenario APIs: FoundryScenario, FoundryStrategy, DatasetConfiguration
  • Exception types and retry decorators
  • Import smoke tests for azure-ai-evaluation (skipped if not installed)

Also adds partner-integration-test target to Makefile.

All 84 tests pass with no Azure credentials required.

Description

Tests and Documentation

slister1001 and others added 3 commits March 24, 2026 11:33
…module

Add tests/partner_integration/azure_ai_evaluation/ with contract tests
validating PyRIT API stability for the azure-ai-evaluation red team module,
which depends on 45+ PyRIT imports across 14 files.

Test coverage includes:
- PromptChatTarget interface contract (extended by 4 SDK classes)
- CentralMemory/SQLiteMemory lifecycle (used in RedTeam.__init__)
- Data models: Message, MessagePiece, Score, seed models, AttackResult
- PromptConverter base + 19 specific converters importability
- Scorer/TrueFalseScorer interface (extended by RAIServiceScorer)
- Foundry scenario APIs: FoundryScenario, FoundryStrategy, DatasetConfiguration
- Exception types and retry decorators
- Import smoke tests for azure-ai-evaluation (skipped if not installed)

Also adds partner-integration-test target to Makefile.

All 84 tests pass with no Azure credentials required.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Fix test_ascii_smuggler_converter_importable to test AsciiSmugglerConverter
  (was incorrectly testing AsciiArtConverter, duplicating parametrized coverage)
- Move module-level asyncio.run(initialize_pyrit_async) to session-scoped fixture
- Remove duplicate TestAttackModels (already covered in test_foundry_contract.py)
- Extract MinimalTarget to module-level helper (was defined 3x inline)
- Add docstring clarifying intentional private API imports in smoke tests

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@slister1001 slister1001 marked this pull request as ready for review March 24, 2026 18:07
pass


class TestPromptChatTargetContract:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

jfyi: we're replacing PromptChatTarget with PromptTarget (https://github.com/Azure/PyRIT/pull/1532) that shouldn't affect the result of these tests (and is a minimal change bc PromptChatTarget doesn't offer a whole lot on top of PromptTarget) but this test will change


def test_foundry_strategy_is_scenario_strategy(self):
"""FoundryStrategy should extend ScenarioStrategy."""
from pyrit.scenario import ScenarioStrategy
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

why isn't this at the top with DatasetConfiguration ?

Comment on lines +64 to +68
def test_callback_chat_target_extends_prompt_chat_target(self):
"""_CallbackChatTarget must be a subclass of pyrit.prompt_target.PromptChatTarget."""
from azure.ai.evaluation.red_team._callback_chat_target import _CallbackChatTarget

assert issubclass(_CallbackChatTarget, PromptChatTarget)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

these would change too. is there a reason we need the explicit inheritance ?


def test_seed_prompt_class_exists(self):
"""DatasetConfigurationBuilder creates SeedPrompt instances."""
assert SeedPrompt is not None
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

i'm assuming there's also a structure you're expecting for the seed models (similar to the message models) ?

…orts, add seed model structural tests

- Update PromptChatTarget to PromptTarget per PR microsoft#1532 deprecation
- Move ScenarioStrategy import to top-level in test_foundry_contract.py
- Add rationale for explicit inheritance checks in test_import_smoke.py
- Expand seed model tests with structural validation (value, data_type,
  harm_categories, role, metadata, SeedGroup composition)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
assert issubclass(FoundryStrategy, ScenarioStrategy)


class TestFoundryScenarioContract:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: rename to RedTeamScenario
(internally there's a bit of an existential crisis going on where half of the classes are named foundry and the other half is redteam but we're moving to RedTeam so I'd try to use that instead)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

as an fyi:

Image

Copy link
Copy Markdown
Contributor

@hannahwestra25 hannahwestra25 left a comment

Choose a reason for hiding this comment

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

a few small comments; will set up the pipeline today!

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