Tests fix
This commit is contained in:
parent
46c998be33
commit
13d52e4987
3 changed files with 36 additions and 12 deletions
|
|
@ -57,7 +57,8 @@ def test_read_flows(client: TestClient, json_flow: str):
|
|||
assert response.json()["name"] == flow.name
|
||||
assert response.json()["data"] == flow.data
|
||||
|
||||
flow_style = FlowStyleCreate(color="red", emoji="👍", flow_id=response.json()["id"])
|
||||
flow_style = FlowStyleCreate(
|
||||
color="red", emoji="👍", flow_id=response.json()["id"])
|
||||
response = client.post(
|
||||
"api/v1/flow_styles/", json=jsonable_encoder(flow_style.dict())
|
||||
)
|
||||
|
|
@ -126,7 +127,8 @@ def test_update_flow(client: TestClient, json_flow: str):
|
|||
description="updated description",
|
||||
data=data,
|
||||
)
|
||||
response = client.patch(f"api/v1/flows/{flow_id}", json=updated_flow.dict())
|
||||
response = client.patch(
|
||||
f"api/v1/flows/{flow_id}", json=updated_flow.dict())
|
||||
assert response.status_code == 200
|
||||
assert response.json()["name"] == updated_flow.name
|
||||
assert response.json()["description"] == updated_flow.description
|
||||
|
|
@ -242,10 +244,12 @@ def test_get_nonexistent_flow(client: TestClient):
|
|||
def test_update_flow_idempotency(client: TestClient, json_flow: str):
|
||||
flow_data = json.loads(json_flow)
|
||||
data = flow_data["data"]
|
||||
flow_data = FlowCreate(name="Test Flow", description="description", data=data)
|
||||
flow_data = FlowCreate(
|
||||
name="Test Flow", description="description", data=data)
|
||||
response = client.post("api/v1/flows/", json=flow_data.dict())
|
||||
flow_id = response.json()["id"]
|
||||
updated_flow = FlowCreate(name="Updated Flow", description="description", data=data)
|
||||
updated_flow = FlowCreate(
|
||||
name="Updated Flow", description="description", data=data)
|
||||
response1 = client.put(f"api/v1/flows/{flow_id}", json=updated_flow.dict())
|
||||
response2 = client.put(f"api/v1/flows/{flow_id}", json=updated_flow.dict())
|
||||
assert response1.json() == response2.json()
|
||||
|
|
@ -309,7 +313,8 @@ def test_create_flow_style(client: TestClient):
|
|||
def test_read_flow_styles(client: TestClient):
|
||||
response = client.get("api/v1/flow_styles/")
|
||||
assert response.status_code == 200
|
||||
flow_styles = [FlowStyleRead(**flow_style) for flow_style in response.json()]
|
||||
flow_styles = [FlowStyleRead(**flow_style)
|
||||
for flow_style in response.json()]
|
||||
assert not flow_styles
|
||||
# Create test data
|
||||
flow_style = FlowStyleCreate(color="red", emoji="🔴")
|
||||
|
|
@ -318,7 +323,8 @@ def test_read_flow_styles(client: TestClient):
|
|||
# Check response data
|
||||
response = client.get("api/v1/flow_styles/")
|
||||
assert response.status_code == 200
|
||||
flow_styles = [FlowStyleRead(**flow_style) for flow_style in response.json()]
|
||||
flow_styles = [FlowStyleRead(**flow_style)
|
||||
for flow_style in response.json()]
|
||||
assert len(flow_styles) == 1
|
||||
assert flow_styles[0].color == flow_style.color
|
||||
assert flow_styles[0].emoji == flow_style.emoji
|
||||
|
|
@ -355,5 +361,7 @@ def test_delete_flow_style(client: TestClient):
|
|||
response = client.delete(f"api/v1/flow_styles/{created_flow_style.id}")
|
||||
assert response.status_code == 200
|
||||
assert response.json() == {"message": "FlowStyle deleted successfully"}
|
||||
response = client.get(f"api/v1/flow_styles/{created_flow_style.id}")
|
||||
assert response.status_code == 404
|
||||
|
||||
with pytest.raises(RuntimeError) as excinfo:
|
||||
response = client.get(f"api/v1/flow_styles/{created_flow_style.id}")
|
||||
assert str(excinfo.value) == "File at path static/index.html does not exist."
|
||||
|
|
|
|||
|
|
@ -371,7 +371,16 @@ def test_chat_open_ai(client: TestClient):
|
|||
"multiline": False,
|
||||
"value": "gpt-3.5-turbo",
|
||||
"password": False,
|
||||
"options": ["gpt-3.5-turbo", "gpt-4", "gpt-4-32k"],
|
||||
"options": [
|
||||
"gpt-3.5-turbo-0613",
|
||||
"gpt-3.5-turbo",
|
||||
"gpt-3.5-turbo-16k-0613",
|
||||
"gpt-3.5-turbo-16k",
|
||||
"gpt-4-0613",
|
||||
"gpt-4-32k-0613",
|
||||
"gpt-4",
|
||||
"gpt-4-32k"
|
||||
],
|
||||
"name": "model_name",
|
||||
"type": "str",
|
||||
"list": True,
|
||||
|
|
@ -478,6 +487,7 @@ def test_chat_open_ai(client: TestClient):
|
|||
== "Wrapper around OpenAI Chat large language models." # noqa E501
|
||||
)
|
||||
assert set(model["base_classes"]) == {
|
||||
"Serializable",
|
||||
"BaseChatModel",
|
||||
"ChatOpenAI",
|
||||
"BaseLanguageModel",
|
||||
|
|
|
|||
|
|
@ -14,7 +14,13 @@ def test_init_build(client):
|
|||
|
||||
|
||||
def test_stream_build(client):
|
||||
client.post("/build/init", json={"id": "stream_test", "data": {"key": "value"}})
|
||||
client.post(
|
||||
"api/v1/build/init",
|
||||
json={
|
||||
"id": "stream_test",
|
||||
"data": {"key": "value"}
|
||||
}
|
||||
)
|
||||
|
||||
# Test the stream
|
||||
response = client.get("api/v1/build/stream/stream_test")
|
||||
|
|
@ -34,8 +40,8 @@ def test_websocket_endpoint(client):
|
|||
|
||||
def test_websocket_endpoint_after_build(client, basic_graph_data):
|
||||
# Assuming your websocket_endpoint uses chat_manager which caches data from stream_build
|
||||
client.post("/build/init", json=basic_graph_data)
|
||||
client.get("/build/stream/websocket_test")
|
||||
client.post("api/v1/build/init", json=basic_graph_data)
|
||||
client.get("api/v1/build/stream/websocket_test")
|
||||
|
||||
# There should be more to test here, but it depends on the inner workings of your websocket handler
|
||||
# and how your chat_manager and other classes behave. The following is just an example structure.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue