parent
140cf890e3
commit
f96f2eaf8a
67 changed files with 421 additions and 361 deletions
|
|
@ -16,28 +16,32 @@ def test_api_exception():
|
|||
}
|
||||
# Expected result
|
||||
|
||||
with patch(
|
||||
"langflow.services.database.models.flow.utils.get_outdated_components", return_value=mock_outdated_components
|
||||
with (
|
||||
patch(
|
||||
"langflow.services.database.models.flow.utils.get_outdated_components",
|
||||
return_value=mock_outdated_components,
|
||||
),
|
||||
patch("langflow.api.utils.get_suggestion_message", return_value=mock_suggestion_message),
|
||||
patch(
|
||||
"langflow.services.database.models.flow.utils.get_components_versions",
|
||||
return_value=mock_component_versions,
|
||||
),
|
||||
):
|
||||
with patch("langflow.api.utils.get_suggestion_message", return_value=mock_suggestion_message):
|
||||
with patch(
|
||||
"langflow.services.database.models.flow.utils.get_components_versions",
|
||||
return_value=mock_component_versions,
|
||||
):
|
||||
# Create an APIException instance
|
||||
api_exception = APIException(mock_exception, mock_flow)
|
||||
# Create an APIException instance
|
||||
api_exception = APIException(mock_exception, mock_flow)
|
||||
|
||||
# Expected body
|
||||
expected_body = ExceptionBody(
|
||||
message="Test exception",
|
||||
suggestion="The flow contains 2 outdated components. We recommend updating the following components: component1, component2.",
|
||||
)
|
||||
# Expected body
|
||||
expected_body = ExceptionBody(
|
||||
message="Test exception",
|
||||
suggestion="The flow contains 2 outdated components. "
|
||||
"We recommend updating the following components: component1, component2.",
|
||||
)
|
||||
|
||||
# Assert the status code
|
||||
assert api_exception.status_code == 500
|
||||
# Assert the status code
|
||||
assert api_exception.status_code == 500
|
||||
|
||||
# Assert the detail
|
||||
assert api_exception.detail == expected_body.model_dump_json()
|
||||
# Assert the detail
|
||||
assert api_exception.detail == expected_body.model_dump_json()
|
||||
|
||||
|
||||
def test_api_exception_no_flow():
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue