Add sede_with_list_output_type_in_pipeline unit test (#8196)

This commit is contained in:
Vladimir Blagojevic 2024-08-13 13:37:24 +01:00 committed by GitHub
parent 1284ca285b
commit 3318d894c0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,6 +1,8 @@
# SPDX-FileCopyrightText: 2022-present deepset GmbH <info@deepset.ai>
#
# SPDX-License-Identifier: Apache-2.0
from typing import List
import json
import pytest
@ -129,6 +131,17 @@ class TestOutputAdapter:
# invoke the custom filter to check if it is deserialized correctly
assert deserialized_adapter.custom_filters["custom_filter"]("test") == "TEST"
def test_sede_with_list_output_type_in_pipeline(self):
pipe = Pipeline()
pipe.add_component("adapter", OutputAdapter(template="{{ test }}", output_type=List[str]))
serialized_pipe = pipe.dumps()
# we serialize the pipeline and check if the output type is serialized correctly (as typing.List[str])
assert "typing.List[str]" in serialized_pipe
deserialized_pipe = Pipeline.loads(serialized_pipe)
assert deserialized_pipe.get_component("adapter").output_type == List[str]
def test_output_adapter_from_dict_custom_filters_none(self):
component = OutputAdapter.from_dict(
data={