feat: add payload validation, update Simple API Test fixture, run tests (#2664)

This commit is contained in:
Gabriel Luiz Freitas Almeida 2024-07-12 15:15:43 -03:00 • committed by GitHub
commit c47c358cad
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 668 additions and 31 deletions

View file

@ -52,6 +52,7 @@ def pytest_configure(config):
pytest.CHAT_INPUT = data_path / "ChatInputTest.json"
pytest.TWO_OUTPUTS = data_path / "TwoOutputsTest.json"
pytest.VECTOR_STORE_PATH = data_path / "Vector_store.json"
pytest.SIMPLE_API_TEST = data_path / "SimpleAPITest.json"
pytest.CODE_WITH_SYNTAX_ERROR = """
def get_text():
retun "Hello World"
@ -211,6 +212,12 @@ def json_flow_with_prompt_and_history():
return f.read()
@pytest.fixture
def json_simple_api_test():
with open(pytest.SIMPLE_API_TEST, "r") as f:
return f.read()
@pytest.fixture
def json_vector_store():
with open(pytest.VECTOR_STORE_PATH, "r") as f:
@ -419,6 +426,20 @@ def created_api_key(active_user):
return api_key
@pytest.fixture(name="simple_api_test")
def get_simple_api_test(client, logged_in_headers, json_simple_api_test):
# Once the client is created, we can get the starter project
# Just create a new flow with the simple api test
flow = orjson.loads(json_simple_api_test)
data = flow["data"]
flow = FlowCreate(name="Simple API Test", data=data, description="Simple API Test")
response = client.post("api/v1/flows/", json=flow.model_dump(), headers=logged_in_headers)
assert response.status_code == 201
assert response.json()["name"] == flow.name
assert response.json()["data"] == flow.data
return response.json()
@pytest.fixture(name="starter_project")
def get_starter_project(active_user):
# once the client is created, we can get the starter project