mirror of
https://github.com/encounter/adk-python.git
synced 2026-07-09 18:19:28 -07:00
chore: Migrate Google tools to use the new feature decorator
Co-authored-by: Xuan Yang <xygoogle@google.com> PiperOrigin-RevId: 842321126
This commit is contained in:
committed by
Copybara-Service
parent
1ae944b39d
commit
bab57296d5
@@ -14,17 +14,25 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import warnings
|
||||
|
||||
from google.adk.features._feature_registry import _WARNED_FEATURES
|
||||
from google.adk.tools.bigquery.config import BigQueryToolConfig
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def reset_warned_features():
|
||||
"""Reset warned features before each test."""
|
||||
_WARNED_FEATURES.clear()
|
||||
|
||||
|
||||
def test_bigquery_tool_config_experimental_warning():
|
||||
"""Test BigQueryToolConfig experimental warning."""
|
||||
with pytest.warns(
|
||||
UserWarning,
|
||||
match="Config defaults may have breaking change in the future.",
|
||||
):
|
||||
with warnings.catch_warnings(record=True) as w:
|
||||
BigQueryToolConfig()
|
||||
assert len(w) == 1
|
||||
assert "BIG_QUERY_TOOL_CONFIG is enabled." in str(w[0].message)
|
||||
|
||||
|
||||
def test_bigquery_tool_config_invalid_property():
|
||||
@@ -46,22 +54,19 @@ def test_bigquery_tool_config_invalid_application_name():
|
||||
|
||||
def test_bigquery_tool_config_max_query_result_rows_default():
|
||||
"""Test BigQueryToolConfig max_query_result_rows default value."""
|
||||
with pytest.warns(UserWarning):
|
||||
config = BigQueryToolConfig()
|
||||
config = BigQueryToolConfig()
|
||||
assert config.max_query_result_rows == 50
|
||||
|
||||
|
||||
def test_bigquery_tool_config_max_query_result_rows_custom():
|
||||
"""Test BigQueryToolConfig max_query_result_rows custom value."""
|
||||
with pytest.warns(UserWarning):
|
||||
config = BigQueryToolConfig(max_query_result_rows=100)
|
||||
config = BigQueryToolConfig(max_query_result_rows=100)
|
||||
assert config.max_query_result_rows == 100
|
||||
|
||||
|
||||
def test_bigquery_tool_config_valid_maximum_bytes_billed():
|
||||
"""Test BigQueryToolConfig raises exception with valid max bytes billed."""
|
||||
with pytest.warns(UserWarning):
|
||||
config = BigQueryToolConfig(maximum_bytes_billed=10_485_760)
|
||||
config = BigQueryToolConfig(maximum_bytes_billed=10_485_760)
|
||||
assert config.maximum_bytes_billed == 10_485_760
|
||||
|
||||
|
||||
@@ -98,8 +103,7 @@ def test_bigquery_tool_config_invalid_maximum_bytes_billed():
|
||||
)
|
||||
def test_bigquery_tool_config_valid_labels(labels):
|
||||
"""Test BigQueryToolConfig accepts valid labels."""
|
||||
with pytest.warns(UserWarning):
|
||||
config = BigQueryToolConfig(job_labels=labels)
|
||||
config = BigQueryToolConfig(job_labels=labels)
|
||||
assert config.job_labels == labels
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user