mirror of
https://github.com/EvolutionAPI/adk-python.git
synced 2025-07-16 20:22:56 -06:00
fix: fix a few unit tests
Copybara import of the project: -- 93cc9c0b71a92991a888c93675ddc8aee11f21dc by luaifei <lu.aifei@thoughtworks.com>: fix: Update skipped tests in test_auth_handlers -- 06ddf559c76c113231719bff549d41801a93daf4 by luaifei <lu.aifei@thoughtworks.com>: fix: Update skipped & failed tests in test_connections_client and test_streaming -- b8f2d357c1101c59ee9b65fa89a75f216e014a7c by luaifei <lu.aifei@thoughtworks.com>: fix: Remove ignored test file from Python unit tests workflow COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/553 from luaifei:fix-tests d51e42841e71d388c16cc719a4798b029182084f PiperOrigin-RevId: 755669644
This commit is contained in:
parent
e4317c9eb7
commit
d5b3a89fe7
1
.github/workflows/python-unit-tests.yml
vendored
1
.github/workflows/python-unit-tests.yml
vendored
@ -36,6 +36,5 @@ jobs:
|
|||||||
source .venv/bin/activate
|
source .venv/bin/activate
|
||||||
pytest tests/unittests \
|
pytest tests/unittests \
|
||||||
--ignore=tests/unittests/artifacts/test_artifact_service.py \
|
--ignore=tests/unittests/artifacts/test_artifact_service.py \
|
||||||
--ignore=tests/unittests/tools/application_integration_tool/clients/test_connections_client.py \
|
|
||||||
--ignore=tests/unittests/tools/google_api_tool/test_googleapi_to_openapi_converter.py
|
--ignore=tests/unittests/tools/google_api_tool/test_googleapi_to_openapi_converter.py
|
||||||
|
|
||||||
|
@ -15,12 +15,12 @@
|
|||||||
import copy
|
import copy
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
|
import pytest
|
||||||
from fastapi.openapi.models import APIKey
|
from fastapi.openapi.models import APIKey
|
||||||
from fastapi.openapi.models import APIKeyIn
|
from fastapi.openapi.models import APIKeyIn
|
||||||
from fastapi.openapi.models import OAuth2
|
from fastapi.openapi.models import OAuth2
|
||||||
from fastapi.openapi.models import OAuthFlowAuthorizationCode
|
from fastapi.openapi.models import OAuthFlowAuthorizationCode
|
||||||
from fastapi.openapi.models import OAuthFlows
|
from fastapi.openapi.models import OAuthFlows
|
||||||
import pytest
|
|
||||||
|
|
||||||
from google.adk.auth.auth_credential import AuthCredential
|
from google.adk.auth.auth_credential import AuthCredential
|
||||||
from google.adk.auth.auth_credential import AuthCredentialTypes
|
from google.adk.auth.auth_credential import AuthCredentialTypes
|
||||||
@ -58,7 +58,7 @@ class MockOAuth2Session:
|
|||||||
self.redirect_uri = redirect_uri
|
self.redirect_uri = redirect_uri
|
||||||
self.state = state
|
self.state = state
|
||||||
|
|
||||||
def create_authorization_url(self, url):
|
def create_authorization_url(self, url, **kwargs):
|
||||||
return f"{url}?client_id={self.client_id}&scope={self.scope}", "mock_state"
|
return f"{url}?client_id={self.client_id}&scope={self.scope}", "mock_state"
|
||||||
|
|
||||||
def fetch_token(
|
def fetch_token(
|
||||||
@ -238,7 +238,6 @@ class TestGetCredentialKey:
|
|||||||
class TestGenerateAuthUri:
|
class TestGenerateAuthUri:
|
||||||
"""Tests for the generate_auth_uri method."""
|
"""Tests for the generate_auth_uri method."""
|
||||||
|
|
||||||
@pytest.mark.skip(reason="broken tests")
|
|
||||||
@patch("google.adk.auth.auth_handler.OAuth2Session", MockOAuth2Session)
|
@patch("google.adk.auth.auth_handler.OAuth2Session", MockOAuth2Session)
|
||||||
def test_generate_auth_uri_oauth2(self, auth_config):
|
def test_generate_auth_uri_oauth2(self, auth_config):
|
||||||
"""Test generating an auth URI for OAuth2."""
|
"""Test generating an auth URI for OAuth2."""
|
||||||
@ -251,7 +250,6 @@ class TestGenerateAuthUri:
|
|||||||
assert "client_id=mock_client_id" in result.oauth2.auth_uri
|
assert "client_id=mock_client_id" in result.oauth2.auth_uri
|
||||||
assert result.oauth2.state == "mock_state"
|
assert result.oauth2.state == "mock_state"
|
||||||
|
|
||||||
@pytest.mark.skip(reason="broken tests")
|
|
||||||
@patch("google.adk.auth.auth_handler.OAuth2Session", MockOAuth2Session)
|
@patch("google.adk.auth.auth_handler.OAuth2Session", MockOAuth2Session)
|
||||||
def test_generate_auth_uri_openid(
|
def test_generate_auth_uri_openid(
|
||||||
self, openid_auth_scheme, oauth2_credentials
|
self, openid_auth_scheme, oauth2_credentials
|
||||||
|
@ -21,7 +21,6 @@ import pytest
|
|||||||
from .. import utils
|
from .. import utils
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.skip(reason='Streaming is hanging.')
|
|
||||||
def test_streaming():
|
def test_streaming():
|
||||||
response1 = LlmResponse(
|
response1 = LlmResponse(
|
||||||
turn_complete=True,
|
turn_complete=True,
|
||||||
|
@ -195,6 +195,7 @@ class TestConnectionsClient:
|
|||||||
"serviceName": "tls_test_service",
|
"serviceName": "tls_test_service",
|
||||||
"host": "test.host",
|
"host": "test.host",
|
||||||
"authOverrideEnabled": True,
|
"authOverrideEnabled": True,
|
||||||
|
"name": "",
|
||||||
}
|
}
|
||||||
|
|
||||||
def test_get_connection_details_success_without_host(
|
def test_get_connection_details_success_without_host(
|
||||||
@ -217,6 +218,7 @@ class TestConnectionsClient:
|
|||||||
"serviceName": "test_service",
|
"serviceName": "test_service",
|
||||||
"host": "",
|
"host": "",
|
||||||
"authOverrideEnabled": False,
|
"authOverrideEnabled": False,
|
||||||
|
"name": "",
|
||||||
}
|
}
|
||||||
|
|
||||||
def test_get_connection_details_error(
|
def test_get_connection_details_error(
|
||||||
@ -431,21 +433,21 @@ class TestConnectionsClient:
|
|||||||
def test_create_operation(self):
|
def test_create_operation(self):
|
||||||
operation = ConnectionsClient.create_operation("Entity1", "test_tool")
|
operation = ConnectionsClient.create_operation("Entity1", "test_tool")
|
||||||
assert "post" in operation
|
assert "post" in operation
|
||||||
assert operation["post"]["summary"] == "Create Entity1"
|
assert operation["post"]["summary"] == "Creates a new Entity1"
|
||||||
assert "operationId" in operation["post"]
|
assert "operationId" in operation["post"]
|
||||||
assert operation["post"]["operationId"] == "test_tool_create_Entity1"
|
assert operation["post"]["operationId"] == "test_tool_create_Entity1"
|
||||||
|
|
||||||
def test_update_operation(self):
|
def test_update_operation(self):
|
||||||
operation = ConnectionsClient.update_operation("Entity1", "test_tool")
|
operation = ConnectionsClient.update_operation("Entity1", "test_tool")
|
||||||
assert "post" in operation
|
assert "post" in operation
|
||||||
assert operation["post"]["summary"] == "Update Entity1"
|
assert operation["post"]["summary"] == "Updates the Entity1"
|
||||||
assert "operationId" in operation["post"]
|
assert "operationId" in operation["post"]
|
||||||
assert operation["post"]["operationId"] == "test_tool_update_Entity1"
|
assert operation["post"]["operationId"] == "test_tool_update_Entity1"
|
||||||
|
|
||||||
def test_delete_operation(self):
|
def test_delete_operation(self):
|
||||||
operation = ConnectionsClient.delete_operation("Entity1", "test_tool")
|
operation = ConnectionsClient.delete_operation("Entity1", "test_tool")
|
||||||
assert "post" in operation
|
assert "post" in operation
|
||||||
assert operation["post"]["summary"] == "Delete Entity1"
|
assert operation["post"]["summary"] == "Delete the Entity1"
|
||||||
assert operation["post"]["operationId"] == "test_tool_delete_Entity1"
|
assert operation["post"]["operationId"] == "test_tool_delete_Entity1"
|
||||||
|
|
||||||
def test_create_operation_request(self):
|
def test_create_operation_request(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user