Skip to content

Commit 385186e

Browse files
yyyu-googlecopybara-github
authored andcommitted
test: for non-stream generate_content, automatic function calling is only available via Chat.send_message. Direct call to Model.generate_content does not support automatic function calling anymore.
PiperOrigin-RevId: 929461973
1 parent c754ebf commit 385186e

11 files changed

Lines changed: 388 additions & 11 deletions

google/genai/tests/afc/test_generate_content_stream_afc.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@
2121
from ... import types
2222

2323

24+
pytestmark = [
25+
pytest.mark.skipif(
26+
"config.getoption('--private')",
27+
reason="AFC logic in private SDK is re-written",
28+
),
29+
]
30+
31+
2432
TEST_NO_AFC_PART = types.Part(
2533
text=(
2634
'Okay, here is the weather in San Francisco'

google/genai/tests/afc/test_should_disable_afc.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,17 @@
1717
"""Tests for should_disable_afc."""
1818

1919
import pytest
20+
from .. import pytest_helper
2021
from ... import types
2122
from ..._extra_utils import should_disable_afc
2223

24+
pytestmark = [
25+
pytest.mark.skipif(
26+
"config.getoption('--private')",
27+
reason="AFC re-written for private SDK",
28+
),
29+
]
30+
2331

2432
def test_config_is_none():
2533
assert should_disable_afc(None) is False

google/genai/tests/chats/test_get_history.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,10 @@ def test_chat_stream_with_empty_content(
562562
assert not chat.get_history(curated=True)
563563

564564

565+
@pytest.mark.skipif(
566+
'config.getoption("--private")',
567+
reason='AFC logic in private is re-written',
568+
)
565569
def test_chat_with_afc_history(mock_generate_content_afc_history):
566570
models_module = models.Models(mock_api_client)
567571
chats_module = chats.Chats(modules=models_module)

google/genai/tests/chats/test_send_message.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,16 @@
4040
raise e
4141

4242

43-
pytestmark = pytest_helper.setup(
44-
file=__file__,
45-
globals_for_file=globals(),
46-
)
43+
pytestmark = [
44+
pytest_helper.setup(
45+
file=__file__,
46+
globals_for_file=globals(),
47+
),
48+
pytest.mark.skipif(
49+
"config.getoption('--private')",
50+
reason="AFC re-written for private SDK",
51+
),
52+
]
4753
pytest_plugins = ('pytest_asyncio',)
4854

4955

google/genai/tests/chats/test_validate_response.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@
1414
#
1515

1616

17+
from ... import chats
1718
from ... import types
18-
from ...chats import _validate_response
19+
20+
_validate_response = chats._validate_response
1921

2022

2123
def test_validate_response_default_response():

google/genai/tests/models/test_function_call_streaming.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,11 @@
148148
test_method='models.generate_content_stream',
149149
)
150150

151+
152+
@pytest.mark.skipif(
153+
'config.getoption("--private")',
154+
reason='in private it was not able to find the replay file',
155+
)
151156
def test_streaming_with_python_native_no_afc_config(client):
152157
"""Tests streaming function calls with native python AFC without disabling AFC."""
153158
if not client.vertexai:
@@ -173,6 +178,10 @@ def test_streaming_with_python_native_no_afc_config(client):
173178
assert 'not compatible with automatic function calling (AFC)' in str(e.value)
174179

175180

181+
@pytest.mark.skipif(
182+
'config.getoption("--private")',
183+
reason='in private it was not able to find the replay file',
184+
)
176185
def test_streaming_with_python_afc_disabled_false(client):
177186
"""Tests streaming function calls with native python AFC without disabling AFC."""
178187
if not client.vertexai:

google/genai/tests/models/test_generate_content.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2159,6 +2159,10 @@ class Foo(BaseModel):
21592159
)
21602160

21612161

2162+
@pytest.mark.skipif(
2163+
'config.getoption("--private")',
2164+
reason='AFC removed from private models.py',
2165+
)
21622166
def test_function(client):
21632167
def get_weather(city: str) -> str:
21642168
"""Returns the weather in a city."""

google/genai/tests/models/test_generate_content_mcp.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,10 @@ async def test_mcp_tools_with_custom_headers_async(client):
105105
}
106106

107107

108+
@pytest.mark.skipif(
109+
'config.getoption("--private")',
110+
reason='AFC by default is disabled in private models.py',
111+
)
108112
@pytest.mark.asyncio
109113
async def test_mcp_tools_subsequent_calls_async(client):
110114
class MockMcpClientSession(McpClientSession):

0 commit comments

Comments
 (0)