diff --git a/tests/conftest.py b/tests/conftest.py index b096356cc..006714303 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -301,3 +301,11 @@ def added_vector_store(client, json_vector_store, logged_in_headers): assert response.json()["name"] == vector_store.name assert response.json()["data"] == vector_store.data return response.json() + + +@pytest.fixture +def test_component_code(): + path = Path(__file__).parent.absolute() / "data" / "test_component.py" + # load the content as a string + with open(path, "r") as f: + return f.read() diff --git a/tests/data/test_component.py b/tests/data/test_component.py new file mode 100644 index 000000000..e801d2feb --- /dev/null +++ b/tests/data/test_component.py @@ -0,0 +1,16 @@ +import random + +from langflow import CustomComponent + + +class TestComponent(CustomComponent): + def refresh_values(self): + # This is a function that will be called every time the component is updated + # and should return a list of random strings + return [f"Random {random.randint(1, 100)}" for _ in range(5)] + + def build_config(self): + return {"param": {"display_name": "Param", "options": self.refresh_values}} + + def build(self, param: int): + return param