10000 fix: fix typo in function name in unit tests(test_rest_api_tool.py) by hangfei · Pull Request #538 · google/adk-python · GitHub
[go: up one dir, main page]

Skip to content

fix: fix typo in function name in unit tests(test_rest_api_tool.py) #538

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

Merged
merged 4 commits into from
May 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ def _process_operation_parameters(self):
schema.description = (
description if not schema.description else schema.description
)
required = param.required
# param.required can be None
required = param.required if param.required is not None else False

self.params.append(
ApiParameter(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -347,9 +347,8 @@ def test_get_json_schema(sample_operation):
assert json_schema['type'] == 'object'
assert 'param1' in json_schema['properties']
assert 'prop1' in json_schema['properties']
assert 'param1' in json_schema['required']
assert 'prop1' in json_schema['required']

# By default nothing is required unless explicitly stated
assert 'required' not in json_schema or json_schema['required'] == []

def test_get_signature_parameters(sample_operation):
"""Test get_signature_parameters method."""
Expand Down
8000
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def mock_operation_parser(self):
return mock_parser

@pytest.fixture
def sample_endpiont(self):
def sample_endpoint(self):
return OperationEndpoint(
base_url="https://example.com", path="/test", method="GET"
)
Expand Down Expand Up @@ -131,38 +131,38 @@ def sample_auth_credential(self):

def test_init(
self,
sample_endpiont,
sample_endpoint,
sample_operation,
sample_auth_scheme,
sample_auth_credential,
):
tool = RestApiTool(
name="test_tool",
description="Test Tool",
endpoint=sample_endpiont,
endpoint=sample_endpoint,
operation=sample_operation,
auth_scheme=sample_auth_scheme,
auth_credential=sample_auth_credential,
)
assert tool.name == "test_tool"
assert tool.description == "Test Tool"
assert tool.endpoint == sample_endpiont
assert tool.endpoint == sample_endpoint
assert tool.operation == sample_operation
assert tool.auth_credential == sample_auth_credential
assert tool.auth_scheme == sample_auth_scheme
assert tool.credential_exchanger is not None

def test_from_parsed_operation_str(
self,
sample_endpiont,
sample_endpoint,
sample_api_parameters,
sample_return_parameter,
sample_operation,
):
parsed_operation_str = json.dumps({
"name": "test_operation",
"description": "Test Description",
"endpoint": sample_endpiont.model_dump(),
"endpoint": sample_endpoint.model_dump(),
"operation": sample_operation.model_dump(),
"auth_scheme": None,
"auth_credential": None,
Expand All @@ -174,12 +174,12 @@ def test_from_parsed_operation_str(
assert tool.name == "test_operation"

def test_get_declaration(
self, sample_endpiont, sample_operation, mock_operation_parser
self, sample_endpoint, sample_operation, mock_operation_parser
):
tool = RestApiTool(
name="test_tool",
description="Test description",
endpoint=sample_endpiont,
endpoint=sample_endpoint,
operation=sample_operation,
should_parse_operation=False,
)
Expand All @@ -198,7 +198,7 @@ def test_call_success(
self,
mock_request,
mock_tool_context,
sample_endpiont,
sample_endpoint,
sample_operation,
sample_auth_scheme,
sample_auth_credential,
Expand All @@ -210,7 +210,7 @@ def test_call_success(
tool = RestApiTool(
name="test_tool",
description="Test Tool",
endpoint=sample_endpiont,
endpoint=sample_endpoint,
operation=sample_operation,
auth_scheme=sample_auth_scheme,
auth_credential=sample_auth_credential,
Expand All @@ -228,7 +228,7 @@ def test_call_success(
def test_call_auth_pending(
self,
mock_request,
sample_endpiont,
sample_endpoint,
sample_operation,
sample_auth_scheme,
sample_auth_credential,
Expand All @@ -237,7 +237,7 @@ def test_call_auth_pending(
tool = RestApiTool(
name="test_tool",
description="Test Tool",
endpoint=sample_endpiont,
endpoint=sample_endpoint,
operation=sample_operation,
auth_scheme=sample_auth_scheme,
auth_credential=sample_auth_credential,
Expand All @@ -258,7 +258,7 @@ def test_call_auth_pending(
}

def test_prepare_request_params_query_body(
self, sample_endpiont, sample_auth_credential, sample_auth_scheme
self, sample_endpoint, sample_auth_credential, sample_auth_scheme
):
# Create a mock Operation object
mock_operation = Operation(
Expand Down Expand Up @@ -288,7 +288,7 @@ def test_prepare_request_params_query_body(
tool = RestApiTool(
name="test_tool",
description="test",
endpoint=sample_endpiont,
endpoint=sample_endpoint,
operation=mock_operation,
auth_credential=sample_auth_credential,
auth_scheme=sample_auth_scheme,
Expand Down Expand Up @@ -327,7 +327,7 @@ def test_prepare_request_params_query_body(
assert request_params["params"] == {"testQueryParam": "query_value"}

def test_prepare_request_params_array(
self, sample_endpiont, sample_auth_scheme, sample_auth_credential
self, sample_endpoint, sample_auth_scheme, sample_auth_credential
):
mock_operation = Operation(
operationId="test_op",
Expand All @@ -345,7 +345,7 @@ def test_prepare_request_params_array(
tool = RestApiTool(
name="test_tool",
description="test",
endpoint=sample_endpiont,
endpoint=sample_endpoint,
operation=mock_operation,
auth_credential=sample_auth_credential,
auth_scheme=sample_auth_scheme,
Expand All @@ -367,7 +367,7 @@ def test_prepare_request_params_array(
assert request_params["json"] == ["item1", "item2"]

def test_prepare_request_params_string(
self, sample_endpiont, sample_auth_credential, sample_auth_scheme
self, sample_endpoint, sample_auth_credential, sample_auth_scheme
):
mock_operation = Operation(
operationId="test_op",
Expand All @@ -380,7 +380,7 @@ def test_prepare_request_params_string(
tool = RestApiTool(
name="test_tool",
description="Test Tool",
endpoint=sample_endpiont,
endpoint=sample_endpoint,
operation=mock_operation,
auth_credential=sample_auth_credential,
auth_scheme=sample_auth_scheme,
Expand All @@ -401,7 +401,7 @@ def test_prepare_request_params_string(
assert request_params["headers"]["Content-Type"] == "text/plain"

def test_prepare_request_params_form_data(
self, sample_endpiont, sample_auth_scheme, sample_auth_credential
self, sample_endpoint, sample_auth_scheme, sample_auth_credential
):
mock_operation = Operation(
operationId="test_op",
Expand All @@ -419,7 +419,7 @@ def test_prepare_request_params_form_data(
tool = RestApiTool(
name="test_tool",
description="test",
endpoint=sample_endpiont,
endpoint=sample_endpoint,
operation=mock_operation,
auth_credential=sample_auth_credential,
auth_scheme=sample_auth_scheme,
Expand All @@ -443,7 +443,7 @@ def test_prepare_request_params_form_data(
)

def test_prepare_request_params_multipart(
self, sample_endpiont, sample_auth_credential, sample_auth_scheme
self, sample_endpoint, sample_auth_credential, sample_auth_scheme
):
mock_operation = Operation(
operationId="test_op",
Expand All @@ -465,7 +465,7 @@ def test_prepare_request_params_multipart(
tool = RestApiTool(
name="test_tool",
description="test",
endpoint=sample_endpiont,
endpoint=sample_endpoint,
operation=mock_operation,
auth_credential=sample_auth_credential,
auth_scheme=sample_auth_scheme,
Expand All @@ -486,7 +486,7 @@ def test_prepare_request_params_multipart(
assert request_params["headers"]["Content-Type"] == "multipart/form-data"

def test_prepare_request_params_octet_stream(
self, sample_endpiont, sample_auth_scheme, sample_auth_credential
self, sample_endpoint, sample_auth_scheme, sample_auth_credential
):
mock_operation = Operation(
operationId="test_op",
Expand All @@ -501,7 +501,7 @@ def test_prepare_request_params_octet_stream(
tool = RestApiTool(
name="test_tool",
description="test",
endpoint=sample_endpiont,
endpoint=sample_endpoint,
operation=mock_operation,
auth_credential=sample_auth_credential,
auth_scheme=sample_auth_scheme,
Expand All @@ -524,13 +524,13 @@ def test_prepare_request_params_octet_stream(
)

def test_prepare_request_params_path_param(
self, sample_endpiont, sample_auth_credential, sample_auth_scheme
self, sample_endpoint, sample_auth_credential, sample_auth_scheme
):
mock_operation = Operation(operationId="test_op")
tool = RestApiTool(
name="test_tool",
description="Test Tool",
endpoint=sample_endpiont,
endpoint=sample_endpoint,
operation=mock_operation,
auth_credential=sample_auth_credential,
auth_scheme=sample_auth_scheme,
Expand All @@ -557,15 +557,15 @@ def test_prepare_request_params_path_param(

def test_prepare_request_params_header_param(
self,
sample_endpiont,
sample_endpoint,
sample_auth_credential,
sample_auth_scheme,
sample_operation,
):
tool = RestApiTool(
name="test_tool",
description="Test Tool",
endpoint=sample_endpiont,
endpoint=sample_endpoint,
operation=sample_operation,
auth_credential=sample_auth_credential,
auth_scheme=sample_auth_scheme,
Expand All @@ -586,15 +586,15 @@ def test_prepare_request_params_header_param(

def test_prepare_request_params_cookie_param(
self,
sample_endpiont,
sample_endpoint,
F438 sample_auth_credential,
sample_auth_scheme,
sample_operation,
):
tool = RestApiTool(
name="test_tool",
description="Test Tool",
endpoint=sample_endpiont,
endpoint=sample_endpoint,
operation=sample_operation,
auth_credential=sample_auth_credential,
auth_scheme=sample_auth_scheme,
Expand All @@ -614,7 +614,7 @@ def test_prepare_request_params_cookie_param(
assert request_params["cookies"]["session_id"] == "cookie_value"

def test_prepare_request_params_multiple_mime_types(
self, sample_endpiont, sample_auth_credential, sample_auth_scheme
self, sample_endpoint, sample_auth_credential, sample_auth_scheme
):
# Test what happens when multiple mime types are specified. It should take
# the first one.
Expand All @@ -632,7 +632,7 @@ def test_prepare_request_params_multiple_mime_types(
tool = RestApiTool(
name="test_tool",
description="Test Tool",
endpoint=sample_endpiont,
endpoint=sample_endpoint,
operation=mock_operation,
auth_credential=sample_auth_credential,
auth_scheme=sample_auth_scheme,
Expand All @@ -653,15 +653,15 @@ def test_prepare_request_params_multiple_mime_types(

def test_prepare_request_params_unknown_parameter(
self,
sample_endpiont,
sample_endpoint,
sample_auth_credential,
sample_auth_scheme,
sample_operation,
):
tool = RestApiTool(
name="test_tool",
description="Test Tool",
endpoint=sample_endpiont,
endpoint=sample_endpoint,
operation=sample_operation,
auth_credential=sample_auth_credential,
auth_scheme=sample_auth_scheme,
Expand Down Expand Up @@ -719,15 +719,15 @@ def test_prepare_request_params_base_url_handling(

def test_prepare_request_params_no_unrecognized_query_parameter(
self,
sample_endpiont,
sample_endpoint,
sample_auth_credential,
sample_auth_scheme,
sample_operation,
):
tool = RestApiTool(
name="test_tool",
description="Test Tool",
endpoint=sample_endpiont,
endpoint=sample_endpoint,
operation=sample_operation,
auth_credential=sample_auth_credential,
auth_scheme=sample_auth_scheme,
Expand All @@ -748,13 +748,13 @@ def test_prepare_request_params_no_unrecognized_query_parameter(

def test_prepare_request_params_no_credential(
self,
sample_endpiont,
sample_endpoint,
sample_operation,
):
tool = RestApiTool(
name="test_tool",
description="Test Tool",
endpoint=sample_endpiont,
endpoint=sample_endpoint,
operation=sample_operation,
auth_credential=None,
auth_scheme=None,
Expand Down
0