langflow/src/backend/tests/unit/test_experimental_components.py
Christophe Bornet 047077cee4
ref: Remove autouse from pytest client fixture (#4158)
Remove autouse from pytest client fixture
2024-10-15 22:55:10 +00:00

20 lines
736 B
Python

from langflow.components import prototypes
def test_python_function_component():
# Arrange
python_function_component = prototypes.PythonFunctionComponent()
# Act
# function must be a string representation
function = "def function():\n return 'Hello, World!'"
python_function_component.function_code = function
# result is the callable function
result = python_function_component.get_function_callable()
result_message = python_function_component.execute_function_message()
result_data = python_function_component.execute_function_data()
# Assert
assert result() == "Hello, World!"
assert result_message.text == "Hello, World!"
assert result_data[0].text == "Hello, World!"