-
Notifications
You must be signed in to change notification settings - Fork 56
Integration package refinements #266
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 12 commits
3cb2022
6e25a90
fd25c32
464ecc6
d1ec76e
6c0a56e
6a57b4c
943fd71
efc7da2
5c77c65
ecb2c6e
3048e19
930bf09
603050d
415264b
cadb843
902d412
b373f31
5329bc4
a37a136
bcca57f
4be418a
329fefa
4e8dca3
61739f4
223a1f8
fae00e9
2d6a9eb
a4e3a25
12f9d90
995d44e
f077099
209c56d
31d5f2f
73205e0
42846ed
ba50824
8dc344c
ba92b0b
66b818c
284ab17
a21a856
54c4981
16b3366
055367a
df11807
a70cbe7
bc55f30
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,5 @@ | ||
| from .basic_sample import BasicSample | ||
| from .quickstart_sample import QuickstartSample | ||
|
|
||
| __all__ = [ | ||
| "BasicSample", | ||
| "QuickstartSample", | ||
| ] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,6 +14,7 @@ test: | |
| name: Test Bot | ||
| text: hi 5 | ||
| locale: en-US | ||
| - skip | ||
| - type: assertion | ||
| quantifier: one | ||
| activity: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,7 +5,7 @@ | |
|
|
||
| from .assertions import ( | ||
| ModelAssertion, | ||
| Selector, | ||
| ModelSelector, | ||
| AssertionQuantifier, | ||
| assert_model, | ||
| assert_field, | ||
|
|
@@ -31,6 +31,8 @@ | |
| DataDrivenTest, | ||
| ) | ||
|
|
||
| from .cli import cli | ||
|
||
|
|
||
| __all__ = [ | ||
| "SDKConfig", | ||
| "generate_token", | ||
|
|
@@ -45,7 +47,7 @@ | |
| "populate_activity", | ||
| "get_host_and_port", | ||
| "ModelAssertion", | ||
| "Selector", | ||
| "ModelSelector", | ||
| "AssertionQuantifier", | ||
| "assert_model", | ||
| "assert_field", | ||
|
|
@@ -56,4 +58,5 @@ | |
| "FieldAssertionType", | ||
| "ddt", | ||
| "DataDrivenTest", | ||
| "cli", | ||
|
||
| ] | ||
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -24,7 +24,12 @@ def _check( | |||
| assertion, assertion_type = _parse_assertion(baseline) | ||||
|
|
||||
| if assertion_type is None: | ||||
|
|
||||
| if isinstance(baseline, dict): | ||||
|
|
||||
| if actual is UNSET_FIELD: | ||||
| actual = {} | ||||
|
|
||||
| for key in baseline: | ||||
| new_field_path = f"{field_path}.{key}" if field_path else key | ||||
| new_actual = actual.get(key, UNSET_FIELD) | ||||
|
|
@@ -38,6 +43,10 @@ def _check( | |||
| return True, None | ||||
|
|
||||
| elif isinstance(baseline, list): | ||||
|
|
||||
|
||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,39 @@ | ||||||
| import os | ||||||
|
|
||||||
| from dotenv import load_dotenv | ||||||
|
|
||||||
| from microsoft_agents.hosting.core import AgentApplication, TurnContext, TurnState | ||||||
|
|
||||||
| from microsoft_agents.testing.integration.core.sample import Sample | ||||||
|
|
||||||
|
|
||||||
| def create_auth_route(auth_handler_id: str, agent: AgentApplication): | ||||||
| def dynamic_function(context: TurnContext, state: TurnState): | ||||||
|
||||||
| def dynamic_function(context: TurnContext, state: TurnState): | |
| async def dynamic_function(context: TurnContext, state: TurnState): |
Outdated
Copilot
AI
Dec 5, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing async keyword on function definition. The function dynamic_function uses await on line 12 but is not declared as async. This will cause a SyntaxError at runtime.
Outdated
Copilot
AI
Dec 2, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The dynamic_function is defined as a synchronous function but uses await. This function should be declared as async def.
Outdated
Copilot
AI
Dec 2, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The class is named QuickstartSample but should be AuthSample based on the file name and context. Additionally, the docstring "A quickstart sample implementation." doesn't accurately describe this authentication-specific sample.
Outdated
Copilot
AI
Dec 2, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing async keyword in function definition. The function contains await on line 12 but is not declared as async, which will cause a SyntaxError.
Change the function signature to:
@classmethod
async def get_config(cls) -> dict:
Outdated
Copilot
AI
Dec 2, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Call to function create_auth_route with too few arguments; should be no fewer than 2.
| create_auth_route(auth_handler.name), | |
| create_auth_route(auth_handler.name, app), |
Outdated
Copilot
AI
Dec 2, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Call to function create_auth_route with too few arguments; should be no fewer than 2.
Outdated
Copilot
AI
Dec 2, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file appears to be a duplicate of dev/microsoft-agents-testing/microsoft_agents/testing/cli/test_auth/auth_sample.py. Having identical code in two locations creates a maintenance burden. Consider consolidating these files or clarifying their distinct purposes.
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,5 @@ | ||||||||
| import cli | ||||||||
|
||||||||
| import cli | |
| from microsoft_agents.testing import cli |
Outdated
Copilot
AI
Dec 2, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Import of 'cli' is not used.
| import cli |
Outdated
Copilot
AI
Dec 2, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The import statement import cli will fail because cli is not a valid module. This appears to be an incomplete or incorrect import that should either import from .cli or be removed entirely.
Outdated
Copilot
AI
Dec 2, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Import of 'cli' is not used.
Outdated
Copilot
AI
Dec 2, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test function test_auth() is empty and provides no test coverage. This placeholder test should either be implemented or removed to avoid misleading test results.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| import os | ||
|
|
||
| from dotenv import load_dotenv | ||
|
|
||
| from microsoft_agents.hosting.core import AgentApplication, TurnContext, TurnState | ||
|
|
||
| from microsoft_agents.testing.integration.core.sample import Sample | ||
|
|
||
|
|
||
| def create_auth_route(auth_handler_id: str, agent: AgentApplication): | ||
| def dynamic_function(context: TurnContext, state: TurnState): | ||
|
||
| token = await agent.auth.get_token(context, state, auth_handler_id) | ||
|
||
|
|
||
| return f"Hello from {auth_handler_id}! Token: {token}" | ||
|
|
||
| dynamic_function.__name__ = f"auth_route_{auth_handler_id}".lower() | ||
| return dynamic_function | ||
|
|
||
|
|
||
| class QuickstartSample(Sample): | ||
|
||
| """A quickstart sample implementation.""" | ||
|
|
||
| @classmethod | ||
| async def get_config(cls) -> dict: | ||
| """Retrieve the configuration for the sample.""" | ||
| load_dotenv("./src/tests/.env") | ||
| return dict(os.environ) | ||
|
|
||
| async def init_app(self): | ||
| """Initialize the application for the quickstart sample.""" | ||
|
|
||
| app: AgentApplication[TurnState] = self.env.agent_application | ||
|
|
||
| for auth_handler in app.config.authentication_handlers: | ||
| app.message( | ||
| auth_handler.name.lower(), | ||
| create_auth_route(auth_handler.name), | ||
|
||
| auth_handlers=[auth_handler.name], | ||
| ) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| import click | ||
|
|
||
| from .auth_sample import AuthSample | ||
|
||
|
|
||
| from microsoft_agents.testing.utils import resolve_env | ||
| from microsoft_agents.testing.core import AiohttpEnvironment | ||
|
||
|
|
||
| @click.command() | ||
| def auth_test(): | ||
| """Run authentication sample test.""" | ||
|
|
||
| environment = AiohttpEnvironment() | ||
| environment.setup() | ||
|
|
||
| sample = AuthSample() | ||
| sample.run(resolve_env) | ||
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The module
cliis being imported and exported in__init__.py, butcli.pyis an empty file. This will cause the import to succeed butcliwill be an empty module object with no useful functionality. Either implement the CLI functionality in this file or remove the import/export from__init__.py.