From 08f04d11d00f922e061c88831a07c13cf046692b Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Fri, 16 Jun 2023 18:53:42 -0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A8=20refactor(tests):=20fix=20formatt?= =?UTF-8?q?ing=20and=20remove=20unnecessary=20lines=20The=20changes=20in?= =?UTF-8?q?=20this=20commit=20are=20purely=20cosmetic.=20The=20code=20has?= =?UTF-8?q?=20been=20reformatted=20to=20improve=20readability=20and=20cons?= =?UTF-8?q?istency.=20Unnecessary=20lines=20have=20been=20removed=20to=20m?= =?UTF-8?q?ake=20the=20code=20more=20concise.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/test_chains_template.py | 10 ++++------ tests/test_database.py | 25 +++++++------------------ tests/test_llms_template.py | 2 +- tests/test_websocket.py | 6 +----- 4 files changed, 13 insertions(+), 30 deletions(-) diff --git a/tests/test_chains_template.py b/tests/test_chains_template.py index 29d947a98..cba973272 100644 --- a/tests/test_chains_template.py +++ b/tests/test_chains_template.py @@ -106,7 +106,7 @@ def test_llm_chain(client: TestClient): "Serializable", "function", "LLMChain", - "Chain" + "Chain", } template = chain["template"] @@ -170,7 +170,7 @@ def test_llm_checker_chain(client: TestClient): "Serializable", "function", "LLMCheckerChain", - "Chain" + "Chain", } template = chain["template"] @@ -188,9 +188,7 @@ def test_llm_checker_chain(client: TestClient): assert template["_type"] == "LLMCheckerChain" # Test the description object - assert ( - chain["description"] == "" - ) + assert chain["description"] == "" def test_llm_math_chain(client: TestClient): @@ -205,7 +203,7 @@ def test_llm_math_chain(client: TestClient): "function", "Serializable", "LLMMathChain", - "Chain" + "Chain", } template = chain["template"] diff --git a/tests/test_database.py b/tests/test_database.py index 5cc3c2174..fd1a59932 100644 --- a/tests/test_database.py +++ b/tests/test_database.py @@ -57,8 +57,7 @@ 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()) ) @@ -121,10 +120,7 @@ def test_update_flow(client: TestClient, json_flow: str): data = flow["data"] flow = FlowCreate(name="Test Flow", description="description", data=data) - response = client.post( - "api/v1/flows/", - json=flow.dict() - ) + response = client.post("api/v1/flows/", json=flow.dict()) flow_id = response.json()["id"] updated_flow = FlowUpdate( @@ -132,10 +128,7 @@ 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 @@ -252,12 +245,10 @@ 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() @@ -321,8 +312,7 @@ 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="🔴") @@ -331,8 +321,7 @@ 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 diff --git a/tests/test_llms_template.py b/tests/test_llms_template.py index 425881b5b..e57c7264a 100644 --- a/tests/test_llms_template.py +++ b/tests/test_llms_template.py @@ -379,7 +379,7 @@ def test_chat_open_ai(client: TestClient): "gpt-4-0613", "gpt-4-32k-0613", "gpt-4", - "gpt-4-32k" + "gpt-4-32k", ], "name": "model_name", "type": "str", diff --git a/tests/test_websocket.py b/tests/test_websocket.py index 7a6a87c8a..9971f5d60 100644 --- a/tests/test_websocket.py +++ b/tests/test_websocket.py @@ -15,11 +15,7 @@ def test_init_build(client): def test_stream_build(client): client.post( - "api/v1/build/init", - json={ - "id": "stream_test", - "data": {"key": "value"} - } + "api/v1/build/init", json={"id": "stream_test", "data": {"key": "value"}} ) # Test the stream