Skip to content

Users/robrandao/data driven tests#244

Closed
rodrigobr-msft wants to merge 75 commits intomainfrom
users/robrandao/data-driven-tests
Closed

Users/robrandao/data driven tests#244
rodrigobr-msft wants to merge 75 commits intomainfrom
users/robrandao/data-driven-tests

Conversation

@rodrigobr-msft
Copy link
Contributor

No description provided.

rodrigobr-msft and others added 25 commits November 6, 2025 11:28
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>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 assertion on line 51. The variable assertion_config is defined as a parameter, but on line 51, it's being accessed as assertion, 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 '
Copy link

Copilot AI Nov 13, 2025

Choose a reason for hiding this comment

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

The docstring on line 34 has a truncated sentence ending with ' (single quote). The description appears to be cut off mid-sentence.

Suggested change
:param selector_config: Configuration dict containing 'selector', 'quantifier', and optionally '
:param selector_config: Configuration dict containing 'selector', 'quantifier', and optionally 'index'.

Copilot uses AI. Check for mistakes.
Comment on lines +1 to +3
from microsoft_agents.testing import DataDrivenTester


Copy link

Copilot AI Nov 13, 2025

Choose a reason for hiding this comment

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

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.

Suggested change
from microsoft_agents.testing import DataDrivenTester
# Minimal DataDrivenTester base class definition
class DataDrivenTester:
def _run_data_driven_test(self, filename):
# Placeholder implementation
pass

Copilot uses AI. Check for mistakes.
activities,
{"selector": selector, "quantifier": SelectorQuantifier.ONE, "index": index},
)
return res[index] if res else None
Copy link

Copilot AI Nov 13, 2025

Choose a reason for hiding this comment

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

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.

Suggested change
return res[index] if res else None
return res[index] if res and 0 <= index < len(res) else None

Copilot uses AI. Check for mistakes.
Comment on lines +29 to +40
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())

Copy link

Copilot AI Nov 13, 2025

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
Comment on lines +168 to +170
def test_invalid_assertion_type(self):
# Passing an unsupported assertion type should return False
assert check_field("test", "test", "INVALID_TYPE") is False
Copy link

Copilot AI Nov 13, 2025

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,141 @@
import json
Copy link

Copilot AI Nov 13, 2025

Choose a reason for hiding this comment

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

Syntax Error (in Python 3).

Copilot uses AI. Check for mistakes.

from microsoft_agents.activity import Activity

from .type_defs import FieldAssertionType, AssertionQuantifier
Copy link

Copilot AI Nov 13, 2025

Choose a reason for hiding this comment

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

Import of 'AssertionQuantifier' is not used.

Suggested change
from .type_defs import FieldAssertionType, AssertionQuantifier
from .type_defs import FieldAssertionType

Copilot uses AI. Check for mistakes.
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.

from typing import Any, TypeVar, Optional
Copy link

Copilot AI Nov 13, 2025

Choose a reason for hiding this comment

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

Import of 'TypeVar' is not used.

Suggested change
from typing import Any, TypeVar, Optional
from typing import Any, Optional

Copilot uses AI. Check for mistakes.
Comment on lines +10 to +13
from microsoft_agents.testing.assertions import (
ActivityAssertion,
assert_activity,
)
Copy link

Copilot AI Nov 13, 2025

Choose a reason for hiding this comment

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

Import of 'assert_activity' is not used.

Copilot uses AI. Check for mistakes.
import asyncio

from copy import deepcopy
from typing import Awaitable, Callable
Copy link

Copilot AI Nov 13, 2025

Choose a reason for hiding this comment

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

Import of 'Awaitable' is not used.
Import of 'Callable' is not used.

Copilot uses AI. Check for mistakes.
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.

1 participant

Comments