forked from langflow-ai/langflow
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: add tests for text input/output components (langflow-ai#3649)
* ci: add tests for text input/output components * ci: add tests for text input/output components * [autofix.ci] apply automated fixes --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
- Loading branch information
1 parent
3eaad7b
commit 9368aef
Showing
3 changed files
with
50 additions
and
2 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
src/backend/tests/integration/components/inputs/test_text_input.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from langflow.schema.message import Message | ||
from tests.integration.utils import run_single_component | ||
|
||
from langflow.components.inputs import TextInputComponent | ||
import pytest | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_text_input(): | ||
outputs = await run_single_component(TextInputComponent, run_input="sample text", input_type="text") | ||
print(outputs) | ||
assert isinstance(outputs["text"], Message) | ||
assert outputs["text"].text == "sample text" | ||
assert outputs["text"].sender is None | ||
assert outputs["text"].sender_name is None | ||
|
||
outputs = await run_single_component(TextInputComponent, run_input="", input_type="text") | ||
assert isinstance(outputs["text"], Message) | ||
assert outputs["text"].text == "" | ||
assert outputs["text"].sender is None | ||
assert outputs["text"].sender_name is None |
23 changes: 23 additions & 0 deletions
23
src/backend/tests/integration/components/outputs/test_text_output.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from langflow.components.outputs import TextOutputComponent | ||
from langflow.schema.message import Message | ||
from tests.integration.utils import run_single_component | ||
|
||
import pytest | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test(): | ||
outputs = await run_single_component(TextOutputComponent, inputs={"input_value": "hello"}) | ||
assert isinstance(outputs["text"], Message) | ||
assert outputs["text"].text == "hello" | ||
assert outputs["text"].sender is None | ||
assert outputs["text"].sender_name is None | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_message(): | ||
outputs = await run_single_component(TextOutputComponent, inputs={"input_value": Message(text="hello")}) | ||
assert isinstance(outputs["text"], Message) | ||
assert outputs["text"].text == "hello" | ||
assert outputs["text"].sender is None | ||
assert outputs["text"].sender_name is None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters