refactor: move tests folder structure and update pytest commands (#2785)

* refactor: move tests folder to src/backend

* chore(Makefile): update pytest commands to run tests from the correct directory paths for unit and integration tests

* refactor: update file path in test_custom_component.py

The file path in the test_custom_component.py file has been updated to use the correct relative path to the component_multiple_outputs.py file. This change ensures that the test code can access the correct file and improves the reliability of the test.
This commit is contained in:
Gabriel Luiz Freitas Almeida 2024-07-18 12:19:43 -03:00 • committed by GitHub
commit 0122a50a35
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
56 changed files with 5 additions and 5 deletions

View file

@ -0,0 +1,35 @@
import os
from typing import List
from langflow.field_typing import Embeddings
def check_env_vars(*vars):
"""
Check if all specified environment variables are set.
Args:
*vars (str): The environment variables to check.
Returns:
bool: True if all environment variables are set, False otherwise.
"""
return all(os.getenv(var) for var in vars)
class MockEmbeddings(Embeddings):
def __init__(self):
self.embedded_documents = None
self.embedded_query = None
@staticmethod
def mock_embedding(text: str):
return [len(text) / 2, len(text) / 5, len(text) / 10]
def embed_documents(self, texts: List[str]) -> List[List[float]]:
self.embedded_documents = texts
return [self.mock_embedding(text) for text in texts]
def embed_query(self, text: str) -> List[float]:
self.embedded_query = text
return self.mock_embedding(text)