ref: Add ALL ruff rules for tests (#4183)

Add ALL ruff rules for tests
This commit is contained in:
Christophe Bornet 2024-10-19 22:41:37 +02:00 • committed by GitHub
commit f96f2eaf8a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
67 changed files with 421 additions and 361 deletions

View file

@ -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():