Another batch of renaming Record to Data
This commit is contained in:
parent
e827789a09
commit
16089ea5b2
61 changed files with 283 additions and 441 deletions
|
|
@ -1,30 +1,31 @@
|
|||
from langchain_core.documents import Document
|
||||
|
||||
from langflow.components import helpers
|
||||
from langflow.custom.utils import build_custom_component_template
|
||||
from langflow.schema import Data
|
||||
|
||||
|
||||
def test_update_record_component():
|
||||
def test_update_data_component():
|
||||
# Arrange
|
||||
update_record_component = helpers.UpdateRecordComponent()
|
||||
update_data_component = helpers.UpdateDataComponent()
|
||||
|
||||
# Act
|
||||
new_data = {"new_key": "new_value"}
|
||||
existing_record = Data(data={"existing_key": "existing_value"})
|
||||
result = update_record_component.build(existing_record, new_data)
|
||||
existing_data = Data(data={"existing_key": "existing_value"})
|
||||
result = update_data_component.build(existing_data, new_data)
|
||||
assert result.data == {"existing_key": "existing_value", "new_key": "new_value"}
|
||||
assert result.existing_key == "existing_value"
|
||||
assert result.new_key == "new_value"
|
||||
|
||||
|
||||
def test_document_to_record_component():
|
||||
def test_document_to_data_component():
|
||||
# Arrange
|
||||
document_to_record_component = helpers.DocumentToRecordComponent()
|
||||
document_to_data_component = helpers.DocumentToDataComponent()
|
||||
|
||||
# Act
|
||||
# Replace with your actual test data
|
||||
document = Document(page_content="key: value", metadata={"url": "https://example.com"})
|
||||
result = document_to_record_component.build(document)
|
||||
result = document_to_data_component.build(document)
|
||||
|
||||
# Assert
|
||||
# Replace with your actual expected result
|
||||
|
|
@ -53,7 +54,7 @@ def test_uuid_generator_component():
|
|||
|
||||
def test_data_as_text_component():
|
||||
# Arrange
|
||||
data_as_text_component = helpers.RecordsToTextComponent()
|
||||
data_as_text_component = helpers.DataToTextComponent()
|
||||
|
||||
# Act
|
||||
# Replace with your actual test data
|
||||
|
|
@ -66,14 +67,14 @@ def test_data_as_text_component():
|
|||
assert result == "Data:{'key': 'value', 'bacon': 'eggs'} -- Bacon:eggs"
|
||||
|
||||
|
||||
def test_text_to_record_component():
|
||||
def test_text_to_data_component():
|
||||
# Arrange
|
||||
text_to_record_component = helpers.CreateRecordComponent()
|
||||
text_to_data_component = helpers.CreateDataComponent()
|
||||
|
||||
# Act
|
||||
# Replace with your actual test data
|
||||
dict_with_text = {"field_1": {"key": "value"}}
|
||||
result = text_to_record_component.build(number_of_fields=1, **dict_with_text)
|
||||
result = text_to_data_component.build(number_of_fields=1, **dict_with_text)
|
||||
|
||||
# Assert
|
||||
# Replace with your actual expected result
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
from langchain_core.documents import Document
|
||||
|
||||
from langflow.schema import Data
|
||||
|
||||
|
||||
def test_record_initialization():
|
||||
def test_data_initialization():
|
||||
record = Data(text_key="msg", data={"msg": "Hello, World!", "extra": "value"})
|
||||
assert record.msg == "Hello, World!"
|
||||
assert record.extra == "value"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue