Conversation
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…erate_token.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…ion/core/environment.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…osoft/Agents-for-python into users/robrandao/integration
There was a problem hiding this comment.
Pull Request Overview
This PR introduces a data-driven testing framework to the microsoft-agents-testing package. The implementation adds assertion utilities for validating bot activities, an integration testing framework with support for various test runners, and configuration files to support data-driven test scenarios.
Key changes:
- New assertion framework with field-level and activity-level validation supporting multiple assertion types (EQUALS, CONTAINS, RE_MATCH, etc.)
- Integration testing infrastructure with agent and response clients for testing bot interactions
- Data-driven test configuration support via YAML files
- Fixed package naming issue in pyproject.toml (was "microsoft-agents-hosting-core", now correctly "microsoft-agents-testing")
Reviewed Changes
Copilot reviewed 45 out of 51 changed files in this pull request and generated 30 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/activity/test_sub_channels.py | Removed empty test class placeholder |
| dev/microsoft-agents-testing/tests/assertions/test_check_field.py | Comprehensive tests for field assertion logic across various types |
| dev/microsoft-agents-testing/tests/assertions/test_assert_activity.py | Tests for activity assertion functionality with multiple assertion types |
| dev/microsoft-agents-testing/tests/assertions/_common.py | Pytest fixtures for activity testing |
| dev/microsoft-agents-testing/pytest.ini | Pytest configuration with test discovery and warning filters |
| dev/microsoft-agents-testing/pyproject.toml | Fixed incorrect package name |
| dev/microsoft-agents-testing/microsoft_agents/testing/assertions/*.py | Core assertion framework implementation |
| dev/microsoft-agents-testing/microsoft_agents/testing/integration/**/*.py | Integration testing framework with client implementations |
| dev/microsoft-agents-testing/microsoft_agents/testing/utils/*.py | Utility functions for activity normalization and URL parsing |
| dev/microsoft-agents-testing/microsoft_agents/testing/auth/*.py | Added copyright headers |
| dev/integration/**/*.py | Example integration tests and data-driven test implementations |
| dev/integration/data_driven_tests/*.yaml | YAML configuration files for data-driven tests |
Comments suppressed due to low confidence (3)
dev/microsoft-agents-testing/microsoft_agents/testing/assertions/assertions.py:52
- Undefined variable
assertionon line 51. The variableassertion_configis defined as a parameter, but on line 51, it's being accessed asassertion, which doesn't exist in this scope.
for activity in activities:
res, assertion_error_data = check_activity_verbose(activity, assertion)
assert res, str(assertion_error_data)
dev/microsoft-agents-testing/microsoft_agents/testing/assertions/assertions.py:45
- Variable quantifier is not used.
quantifier = assertion_config.get(
dev/microsoft-agents-testing/microsoft_agents/testing/integration/data_driven/ddt.py:29
- Syntax Error (in Python 3).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| """Selects activities from a list based on the provided selector configuration. | ||
|
|
||
| :param activities: List of activities to select from. | ||
| :param selector_config: Configuration dict containing 'selector', 'quantifier', and optionally ' |
There was a problem hiding this comment.
The docstring on line 34 has a truncated sentence ending with ' (single quote). The description appears to be cut off mid-sentence.
| :param selector_config: Configuration dict containing 'selector', 'quantifier', and optionally ' | |
| :param selector_config: Configuration dict containing 'selector', 'quantifier', and optionally 'index'. |
| from microsoft_agents.testing import DataDrivenTester | ||
|
|
||
|
|
There was a problem hiding this comment.
Missing import statement. The DataDrivenTester class is imported and used on lines 1 and 4, but this class doesn't appear to be exported from microsoft_agents.testing based on the __init__.py file shown in the PR.
| from microsoft_agents.testing import DataDrivenTester | |
| # Minimal DataDrivenTester base class definition | |
| class DataDrivenTester: | |
| def _run_data_driven_test(self, filename): | |
| # Placeholder implementation | |
| pass |
| activities, | ||
| {"selector": selector, "quantifier": SelectorQuantifier.ONE, "index": index}, | ||
| ) | ||
| return res[index] if res else None |
There was a problem hiding this comment.
Potential index out of bounds error on line 25. The function returns res[index] without checking if the index is valid for the result list. If res is shorter than index + 1, this will raise an IndexError.
| return res[index] if res else None | |
| return res[index] if res and 0 <= index < len(res) else None |
| async def func(self, agent_client, response_client) -> None: | ||
| ddt = DataDrivenTest(test_path) | ||
|
|
||
| responses = [] | ||
|
|
||
| await for step in ddt: | ||
| if isinstance(step, Activity): | ||
| await agent_client.send_activity(step) | ||
| elif isinstance(step, dict): | ||
| # assertion | ||
| responses.extend(await response_client.pop()) | ||
|
|
There was a problem hiding this comment.
The async def func function at line 29 contains invalid async syntax at line 34. The statement await for step in ddt: is incorrect - it should be either async for step in ddt: (for async iteration) or the function needs to be redesigned. Additionally, the ddt object is not shown to implement async iteration, and Activity is not imported.
| def test_invalid_assertion_type(self): | ||
| # Passing an unsupported assertion type should return False | ||
| assert check_field("test", "test", "INVALID_TYPE") is False |
There was a problem hiding this comment.
The check_field function can raise a ValueError for unsupported assertion types (line 71), but in the test on line 170, an invalid assertion type "INVALID_TYPE" is expected to return False instead of raising an exception. This is inconsistent behavior - the implementation raises an error but the test expects False.
| @@ -0,0 +1,141 @@ | |||
| import json | |||
There was a problem hiding this comment.
Syntax Error (in Python 3).
|
|
||
| from microsoft_agents.activity import Activity | ||
|
|
||
| from .type_defs import FieldAssertionType, AssertionQuantifier |
There was a problem hiding this comment.
Import of 'AssertionQuantifier' is not used.
| from .type_defs import FieldAssertionType, AssertionQuantifier | |
| from .type_defs import FieldAssertionType |
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. | ||
|
|
||
| from typing import Any, TypeVar, Optional |
There was a problem hiding this comment.
Import of 'TypeVar' is not used.
| from typing import Any, TypeVar, Optional | |
| from typing import Any, Optional |
| from microsoft_agents.testing.assertions import ( | ||
| ActivityAssertion, | ||
| assert_activity, | ||
| ) |
There was a problem hiding this comment.
Import of 'assert_activity' is not used.
| import asyncio | ||
|
|
||
| from copy import deepcopy | ||
| from typing import Awaitable, Callable |
There was a problem hiding this comment.
Import of 'Awaitable' is not used.
Import of 'Callable' is not used.
No description provided.