|
8 | 8 | from haystack.document_stores.in_memory.document_store import InMemoryDocumentStore
|
9 | 9 | from haystack.utils.deserialization import (
|
10 | 10 | deserialize_document_store_in_init_params_inplace,
|
11 |
| - deserialize_chatgenerator_inplace, |
| 11 | + deserialize_component_inplace, |
12 | 12 | )
|
13 | 13 | from haystack.core.errors import DeserializationError
|
14 | 14 | from haystack.components.generators.chat.openai import OpenAIChatGenerator
|
@@ -97,38 +97,37 @@ def test_invalid_class_import(self):
|
97 | 97 | deserialize_document_store_in_init_params_inplace(data)
|
98 | 98 |
|
99 | 99 |
|
100 |
| -class TestDeserializeChatGeneratorInplace: |
101 |
| - def test_deserialize_chatgenerator_inplace(self, monkeypatch): |
| 100 | +class TestDeserializeComponentInplace: |
| 101 | + def test_deserialize_component_inplace(self, monkeypatch): |
102 | 102 | monkeypatch.setenv("OPENAI_API_KEY", "test-api-key")
|
103 | 103 | chat_generator = OpenAIChatGenerator()
|
104 | 104 | data = {"chat_generator": chat_generator.to_dict()}
|
105 |
| - |
106 |
| - deserialize_chatgenerator_inplace(data) |
| 105 | + deserialize_component_inplace(data) |
107 | 106 | assert isinstance(data["chat_generator"], OpenAIChatGenerator)
|
108 | 107 | assert data["chat_generator"].to_dict() == chat_generator.to_dict()
|
109 | 108 |
|
110 |
| - def test_missing_chat_generator_key(self): |
| 109 | + def test_missing_key(self): |
111 | 110 | data = {"some_key": "some_value"}
|
112 | 111 | with pytest.raises(DeserializationError):
|
113 |
| - deserialize_chatgenerator_inplace(data) |
| 112 | + deserialize_component_inplace(data) |
114 | 113 |
|
115 |
| - def test_chat_generator_is_not_a_dict(self): |
| 114 | + def test_component_is_not_a_dict(self): |
116 | 115 | data = {"chat_generator": "not_a_dict"}
|
117 | 116 | with pytest.raises(DeserializationError):
|
118 |
| - deserialize_chatgenerator_inplace(data) |
| 117 | + deserialize_component_inplace(data) |
119 | 118 |
|
120 | 119 | def test_type_key_missing(self):
|
121 | 120 | data = {"chat_generator": {"some_key": "some_value"}}
|
122 | 121 | with pytest.raises(DeserializationError):
|
123 |
| - deserialize_chatgenerator_inplace(data) |
| 122 | + deserialize_component_inplace(data) |
124 | 123 |
|
125 | 124 | def test_class_not_correctly_imported(self):
|
126 | 125 | data = {"chat_generator": {"type": "invalid.module.InvalidClass"}}
|
127 | 126 | with pytest.raises(DeserializationError):
|
128 |
| - deserialize_chatgenerator_inplace(data) |
| 127 | + deserialize_component_inplace(data) |
129 | 128 |
|
130 |
| - def test_chat_generator_no_from_dict_method(self): |
| 129 | + def test_component_no_from_dict_method(self): |
131 | 130 | chat_generator = ChatGeneratorWithoutFromDict()
|
132 | 131 | data = {"chat_generator": chat_generator.to_dict()}
|
133 |
| - deserialize_chatgenerator_inplace(data) |
| 132 | + deserialize_component_inplace(data) |
134 | 133 | assert isinstance(data["chat_generator"], ChatGeneratorWithoutFromDict)
|
0 commit comments