🔥 refactor(custom.py): remove unused code and class 'CustomComponent_old' to improve code cleanliness and maintainability

🔧 fix(test_custom_component.py): fix formatting issues in test_custom_component.py for better readability
 feat(test_custom_component.py): add import statements for 'patch' and 'MagicMock' to enable mocking in tests
🔬 test(test_custom_component.py): add test for the 'get_function' method of the Component class with valid code and function_entrypoint_name
🔬 test(test_custom_component.py): add test for the 'parse_assign' method of the CodeParser class
🔬 test(test_custom_component.py): add test for the 'get_code_tree' method of the Component class when given incorrect syntax
🔬 test(test_custom_component.py): add test for the '_class_template_validation' method of the CustomComponent class when the code is None
🔬 test(test_custom_component.py): add test for the 'get_function_entrypoint_args' method of the CustomComponent class
🔬 test(test_custom_component.py): add test for the 'get_function_entrypoint_return_type' method of the CustomComponent class
🔬 test(test_custom_component.py): add test for the 'get_main_class_name' method of the CustomComponent class when there is no main class

🔥 refactor(test_custom_component.py): remove commented out code and unused fixtures to improve code readability and maintainability

🔧 refactor(tests): remove commented out test cases and unused imports
 feat(tests): add new test case for list_flows method when there are no flows in the database
 feat(tests): add new test case for build_config method when code is not provided
 feat(tests): add new test case for list_flows method when there are multiple queries to the database
This commit is contained in:
gustavoschaedler 2023-07-26 16:56:21 +01:00
commit a89a9a3267
2 changed files with 28 additions and 473 deletions

View file

@ -48,29 +48,3 @@ class PythonFunctionTool(Function, Tool):
class PythonFunction(Function):
code: str
class CustomComponent_old(BaseModel):
code: str
function: Optional[Callable] = None
imports: Optional[str] = None
# Eval code and store the class
def __init__(self, **data):
super().__init__(**data)
# Validate the Class code
@validator("code")
def validate_func(cls, v):
try:
validate.eval_function(v)
except Exception as e:
raise e
return v
def get_function(self):
"""Get the function"""
function_name = validate.extract_function_name(self.code)
return validate.create_function(self.code, function_name)