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:
luaifei 2025-05-06 21:44:50 -07:00 committed by Copybara-Service
parent e4317c9eb7
commit d5b3a89fe7
4 changed files with 7 additions and 9 deletions

View File

@ -36,6 +36,5 @@ jobs:
source .venv/bin/activate
pytest tests/unittests \
--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

View File

@ -15,12 +15,12 @@
import copy
from unittest.mock import patch
import pytest
from fastapi.openapi.models import APIKey
from fastapi.openapi.models import APIKeyIn
from fastapi.openapi.models import OAuth2
from fastapi.openapi.models import OAuthFlowAuthorizationCode
from fastapi.openapi.models import OAuthFlows
import pytest
from google.adk.auth.auth_credential import AuthCredential
from google.adk.auth.auth_credential import AuthCredentialTypes
@ -58,7 +58,7 @@ class MockOAuth2Session:
self.redirect_uri = redirect_uri
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"
def fetch_token(
@ -238,7 +238,6 @@ class TestGetCredentialKey:
class TestGenerateAuthUri:
"""Tests for the generate_auth_uri method."""
@pytest.mark.skip(reason="broken tests")
@patch("google.adk.auth.auth_handler.OAuth2Session", MockOAuth2Session)
def test_generate_auth_uri_oauth2(self, auth_config):
"""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 result.oauth2.state == "mock_state"
@pytest.mark.skip(reason="broken tests")
@patch("google.adk.auth.auth_handler.OAuth2Session", MockOAuth2Session)
def test_generate_auth_uri_openid(
self, openid_auth_scheme, oauth2_credentials

View File

@ -21,7 +21,6 @@ import pytest
from .. import utils
@pytest.mark.skip(reason='Streaming is hanging.')
def test_streaming():
response1 = LlmResponse(
turn_complete=True,

View File

@ -195,6 +195,7 @@ class TestConnectionsClient:
"serviceName": "tls_test_service",
"host": "test.host",
"authOverrideEnabled": True,
"name": "",
}
def test_get_connection_details_success_without_host(
@ -217,6 +218,7 @@ class TestConnectionsClient:
"serviceName": "test_service",
"host": "",
"authOverrideEnabled": False,
"name": "",
}
def test_get_connection_details_error(
@ -431,21 +433,21 @@ class TestConnectionsClient:
def test_create_operation(self):
operation = ConnectionsClient.create_operation("Entity1", "test_tool")
assert "post" in operation
assert operation["post"]["summary"] == "Create Entity1"
assert operation["post"]["summary"] == "Creates a new Entity1"
assert "operationId" in operation["post"]
assert operation["post"]["operationId"] == "test_tool_create_Entity1"
def test_update_operation(self):
operation = ConnectionsClient.update_operation("Entity1", "test_tool")
assert "post" in operation
assert operation["post"]["summary"] == "Update Entity1"
assert operation["post"]["summary"] == "Updates the Entity1"
assert "operationId" in operation["post"]
assert operation["post"]["operationId"] == "test_tool_update_Entity1"
def test_delete_operation(self):
operation = ConnectionsClient.delete_operation("Entity1", "test_tool")
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"
def test_create_operation_request(self):