The following changes were made: - Removed the `custom_chain` fixture and the `MyCustomChain` and `CustomChain` classes as they were not being used. - Removed the `data_processing`, `filter_docs`, `get_request`, and `post_request` fixtures as they were not being used. 🔧 fix(test_agents_template.py): set "dynamic" property to False for all template variables to ensure consistency and improve clarity 🐛 fix(test_chains_template.py): add missing "dynamic" field to template dictionaries to ensure consistency and avoid potential bugs 🔧 fix(test_custom_component.py): fix import statements and remove unused imports to improve code readability and maintainability ✨ feat(test_custom_component.py): add tests for the initialization of the CodeParser, Component, and CustomComponent classes 🔧 fix(test_custom_component.py): fix test names and add missing test cases for the Component and CustomComponent classes 🔨 refactor: refactor server.ts to use uppercase PORT variable for improved semantics ✨ feat: add support for process.env.PORT environment variable to run app on configurable port 🔨 refactor: refactor CustomComponent tests for improved readability and maintainability 🔨 refactor: refactor CodeParser tests for improved readability and maintainability 🔨 refactor: refactor Component tests for improved readability and maintainability 🐛 fix: fix CustomComponent class template validation to raise HTTPException when code is None 🔧 fix(tests): fix syntax error in custom_component._class_template_validation ✨ feat(tests): add test_custom_component_get_code_tree_syntax_error to test CustomComponent.get_code_tree method for raising CodeSyntaxError when given incorrect syntax ✨ feat(tests): add test_custom_component_get_function_entrypoint_args_no_args to test CustomComponent.get_function_entrypoint_args property with a build method with no arguments ✨ feat(tests): add test_custom_component_get_function_entrypoint_return_type_no_return_type to test CustomComponent.get_function_entrypoint_return_type property with a build method with no return type ✨ feat(tests): add test_custom_component_get_main_class_name_no_main_class to test CustomComponent.get_main_class_name property when there is no main class ✨ feat(tests): add test_custom_component_build_not_implemented to test CustomComponent.build method for raising NotImplementedError ✨ feat(tests): add fixtures for custom_chain, data_processing, filter_docs, and get_request 🔧 fix(tests): remove commented out code and unused imports to improve code readability and maintainability 🐛 fix(test_llms_template.py): set "dynamic" property to False for all template properties to ensure static values are used 🐛 fix(test_prompts_template.py): set "dynamic" property to False for all template properties to ensure consistency and improve readability
51 lines
1.6 KiB
Python
51 lines
1.6 KiB
Python
from typing import Dict, List
|
|
|
|
import pytest
|
|
from langflow.interface.agents.base import AgentCreator
|
|
from langflow.interface.base import LangChainTypeCreator
|
|
|
|
|
|
@pytest.fixture
|
|
def sample_lang_chain_type_creator() -> LangChainTypeCreator:
|
|
class SampleLangChainTypeCreator(LangChainTypeCreator):
|
|
type_name: str = "test_type"
|
|
|
|
def type_to_loader_dict(self) -> Dict: # type: ignore
|
|
return {"test_type": "TestClass"}
|
|
|
|
def to_list(self) -> List[str]:
|
|
return ["node1", "node2"]
|
|
|
|
def get_signature(self, name: str) -> Dict:
|
|
return {
|
|
"template": {"test_field": {"type": "str"}},
|
|
"description": "test description",
|
|
"base_classes": ["base_class1", "base_class2"],
|
|
}
|
|
|
|
return SampleLangChainTypeCreator()
|
|
|
|
|
|
@pytest.fixture
|
|
def sample_agent_creator() -> AgentCreator:
|
|
return AgentCreator()
|
|
|
|
|
|
def test_lang_chain_type_creator_to_dict(
|
|
sample_lang_chain_type_creator: LangChainTypeCreator,
|
|
):
|
|
type_dict = sample_lang_chain_type_creator.to_dict()
|
|
|
|
assert len(type_dict) == 1
|
|
assert "test_type" in type_dict
|
|
assert "node1" in type_dict["test_type"]
|
|
assert "node2" in type_dict["test_type"]
|
|
assert "template" in type_dict["test_type"]["node1"]
|
|
assert "description" in type_dict["test_type"]["node1"]
|
|
assert "base_classes" in type_dict["test_type"]["node1"]
|
|
|
|
|
|
def test_agent_creator_type_to_loader_dict(sample_agent_creator: AgentCreator):
|
|
type_to_loader_dict = sample_agent_creator.type_to_loader_dict
|
|
assert len(type_to_loader_dict) > 0
|
|
assert "JsonAgent"
|