Files
wehub-resource-sync c56bef871b
CodeQL / Analyze (python) (push) Has been cancelled
Update Platform Components Table / update (push) Has been cancelled
Docker image release / Build base image (push) Has been cancelled
Sync docs with Docusaurus / sync (push) Has been cancelled
Tests / Check if changed (push) Has been cancelled
Tests / format (push) Has been cancelled
Tests / check-imports (push) Has been cancelled
Tests / Unit / macos-latest (push) Has been cancelled
Tests / Unit / ubuntu-latest (push) Has been cancelled
Tests / Unit / windows-latest (push) Has been cancelled
Tests / mypy (push) Has been cancelled
Tests / Integration / ubuntu-latest (push) Has been cancelled
Tests / Integration / macos-latest (push) Has been cancelled
Tests / Integration / windows-latest (push) Has been cancelled
Tests / notify-slack-on-failure (push) Has been cancelled
Tests / Mark tests as completed (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:22:28 +08:00

37 lines
1.2 KiB
Python

# SPDX-FileCopyrightText: 2022-present deepset GmbH <info@deepset.ai>
#
# SPDX-License-Identifier: Apache-2.0
import pytest
from haystack.components.joiners import BranchJoiner
class TestBranchJoiner:
def test_one_value(self):
joiner = BranchJoiner(int)
output = joiner.run(value=[2])
assert output == {"value": 2}
def test_one_value_of_wrong_type(self):
# BranchJoiner does not type check the input
joiner = BranchJoiner(int)
output = joiner.run(value=["hello"])
assert output == {"value": "hello"}
def test_one_value_of_none_type(self):
# BranchJoiner does not type check the input
joiner = BranchJoiner(int)
output = joiner.run(value=[None])
assert output == {"value": None}
def test_more_values_of_expected_type(self):
joiner = BranchJoiner(int)
with pytest.raises(ValueError, match="BranchJoiner expects only one input, but 3 were received."):
joiner.run(value=[2, 3, 4])
def test_no_values(self):
joiner = BranchJoiner(int)
with pytest.raises(ValueError, match="BranchJoiner expects only one input, but 0 were received."):
joiner.run(value=[])