🔨 refactor(tests): fix formatting and remove unnecessary lines

The changes in this commit are purely cosmetic. The code has been reformatted to improve readability and consistency. Unnecessary lines have been removed to make the code more concise.
This commit is contained in:
Gabriel Luiz Freitas Almeida 2023-06-16 18:53:42 -03:00
commit 08f04d11d0
4 changed files with 13 additions and 30 deletions

View file

@ -106,7 +106,7 @@ def test_llm_chain(client: TestClient):
"Serializable", "Serializable",
"function", "function",
"LLMChain", "LLMChain",
"Chain" "Chain",
} }
template = chain["template"] template = chain["template"]
@ -170,7 +170,7 @@ def test_llm_checker_chain(client: TestClient):
"Serializable", "Serializable",
"function", "function",
"LLMCheckerChain", "LLMCheckerChain",
"Chain" "Chain",
} }
template = chain["template"] template = chain["template"]
@ -188,9 +188,7 @@ def test_llm_checker_chain(client: TestClient):
assert template["_type"] == "LLMCheckerChain" assert template["_type"] == "LLMCheckerChain"
# Test the description object # Test the description object
assert ( assert chain["description"] == ""
chain["description"] == ""
)
def test_llm_math_chain(client: TestClient): def test_llm_math_chain(client: TestClient):
@ -205,7 +203,7 @@ def test_llm_math_chain(client: TestClient):
"function", "function",
"Serializable", "Serializable",
"LLMMathChain", "LLMMathChain",
"Chain" "Chain",
} }
template = chain["template"] template = chain["template"]

View file

@ -57,8 +57,7 @@ def test_read_flows(client: TestClient, json_flow: str):
assert response.json()["name"] == flow.name assert response.json()["name"] == flow.name
assert response.json()["data"] == flow.data assert response.json()["data"] == flow.data
flow_style = FlowStyleCreate( flow_style = FlowStyleCreate(color="red", emoji="👍", flow_id=response.json()["id"])
color="red", emoji="👍", flow_id=response.json()["id"])
response = client.post( response = client.post(
"api/v1/flow_styles/", json=jsonable_encoder(flow_style.dict()) "api/v1/flow_styles/", json=jsonable_encoder(flow_style.dict())
) )
@ -121,10 +120,7 @@ def test_update_flow(client: TestClient, json_flow: str):
data = flow["data"] data = flow["data"]
flow = FlowCreate(name="Test Flow", description="description", data=data) flow = FlowCreate(name="Test Flow", description="description", data=data)
response = client.post( response = client.post("api/v1/flows/", json=flow.dict())
"api/v1/flows/",
json=flow.dict()
)
flow_id = response.json()["id"] flow_id = response.json()["id"]
updated_flow = FlowUpdate( updated_flow = FlowUpdate(
@ -132,10 +128,7 @@ def test_update_flow(client: TestClient, json_flow: str):
description="updated description", description="updated description",
data=data, data=data,
) )
response = client.patch( response = client.patch(f"api/v1/flows/{flow_id}", json=updated_flow.dict())
f"api/v1/flows/{flow_id}",
json=updated_flow.dict()
)
assert response.status_code == 200 assert response.status_code == 200
assert response.json()["name"] == updated_flow.name assert response.json()["name"] == updated_flow.name
@ -252,12 +245,10 @@ def test_get_nonexistent_flow(client: TestClient):
def test_update_flow_idempotency(client: TestClient, json_flow: str): def test_update_flow_idempotency(client: TestClient, json_flow: str):
flow_data = json.loads(json_flow) flow_data = json.loads(json_flow)
data = flow_data["data"] data = flow_data["data"]
flow_data = FlowCreate( flow_data = FlowCreate(name="Test Flow", description="description", data=data)
name="Test Flow", description="description", data=data)
response = client.post("api/v1/flows/", json=flow_data.dict()) response = client.post("api/v1/flows/", json=flow_data.dict())
flow_id = response.json()["id"] flow_id = response.json()["id"]
updated_flow = FlowCreate( updated_flow = FlowCreate(name="Updated Flow", description="description", data=data)
name="Updated Flow", description="description", data=data)
response1 = client.put(f"api/v1/flows/{flow_id}", json=updated_flow.dict()) 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()) response2 = client.put(f"api/v1/flows/{flow_id}", json=updated_flow.dict())
assert response1.json() == response2.json() assert response1.json() == response2.json()
@ -321,8 +312,7 @@ def test_create_flow_style(client: TestClient):
def test_read_flow_styles(client: TestClient): def test_read_flow_styles(client: TestClient):
response = client.get("api/v1/flow_styles/") response = client.get("api/v1/flow_styles/")
assert response.status_code == 200 assert response.status_code == 200
flow_styles = [FlowStyleRead(**flow_style) flow_styles = [FlowStyleRead(**flow_style) for flow_style in response.json()]
for flow_style in response.json()]
assert not flow_styles assert not flow_styles
# Create test data # Create test data
flow_style = FlowStyleCreate(color="red", emoji="🔴") flow_style = FlowStyleCreate(color="red", emoji="🔴")
@ -331,8 +321,7 @@ def test_read_flow_styles(client: TestClient):
# Check response data # Check response data
response = client.get("api/v1/flow_styles/") response = client.get("api/v1/flow_styles/")
assert response.status_code == 200 assert response.status_code == 200
flow_styles = [FlowStyleRead(**flow_style) flow_styles = [FlowStyleRead(**flow_style) for flow_style in response.json()]
for flow_style in response.json()]
assert len(flow_styles) == 1 assert len(flow_styles) == 1
assert flow_styles[0].color == flow_style.color assert flow_styles[0].color == flow_style.color
assert flow_styles[0].emoji == flow_style.emoji assert flow_styles[0].emoji == flow_style.emoji

View file

@ -379,7 +379,7 @@ def test_chat_open_ai(client: TestClient):
"gpt-4-0613", "gpt-4-0613",
"gpt-4-32k-0613", "gpt-4-32k-0613",
"gpt-4", "gpt-4",
"gpt-4-32k" "gpt-4-32k",
], ],
"name": "model_name", "name": "model_name",
"type": "str", "type": "str",

View file

@ -15,11 +15,7 @@ def test_init_build(client):
def test_stream_build(client): def test_stream_build(client):
client.post( client.post(
"api/v1/build/init", "api/v1/build/init", json={"id": "stream_test", "data": {"key": "value"}}
json={
"id": "stream_test",
"data": {"key": "value"}
}
) )
# Test the stream # Test the stream