ruff format

This commit is contained in:
Gabriel Luiz Freitas Almeida 2023-11-13 18:32:34 -03:00
commit e4d8687a09
115 changed files with 494 additions and 1505 deletions

View file

@ -31,10 +31,7 @@ def poll_task_status(client, headers, href, max_attempts=20, sleep_time=1):
href,
headers=headers,
)
if (
task_status_response.status_code == 200
and task_status_response.json()["status"] == "SUCCESS"
):
if task_status_response.status_code == 200 and task_status_response.json()["status"] == "SUCCESS":
return task_status_response.json()
time.sleep(sleep_time)
return None # Return None if task did not complete in time
@ -130,11 +127,7 @@ def created_api_key(active_user):
)
db_manager = get_db_service()
with session_getter(db_manager) as session:
if (
existing_api_key := session.query(ApiKey)
.filter(ApiKey.api_key == api_key.api_key)
.first()
):
if existing_api_key := session.query(ApiKey).filter(ApiKey.api_key == api_key.api_key).first():
return existing_api_key
session.add(api_key)
session.commit()
@ -193,9 +186,7 @@ def test_process_flow_invalid_id(client, monkeypatch, created_api_key):
}
invalid_id = uuid.uuid4()
response = client.post(
f"api/v1/process/{invalid_id}", headers=headers, json=post_data
)
response = client.post(f"api/v1/process/{invalid_id}", headers=headers, json=post_data)
assert response.status_code == 404
assert f"Flow {invalid_id} not found" in response.json()["detail"]
@ -236,9 +227,7 @@ def test_process_flow_without_autologin(client, flow, monkeypatch, created_api_k
monkeypatch.setattr(endpoints, "process_graph_cached", mock_process_graph_cached)
monkeypatch.setattr(crud, "update_total_uses", mock_update_total_uses)
monkeypatch.setattr(
endpoints, "process_graph_cached_task", mock_process_graph_cached_task
)
monkeypatch.setattr(endpoints, "process_graph_cached_task", mock_process_graph_cached_task)
api_key = created_api_key.api_key
headers = {"x-api-key": api_key}
@ -510,9 +499,7 @@ def test_basic_chat_with_two_session_ids_and_names(client, added_flow, created_a
@pytest.mark.async_test
def test_vector_store_in_process(
distributed_client, added_vector_store, created_api_key
):
def test_vector_store_in_process(distributed_client, added_vector_store, created_api_key):
# Run the /api/v1/process/{flow_id} endpoint
headers = {"x-api-key": created_api_key.api_key}
post_data = {"inputs": {"input": "What is Langflow?"}}
@ -563,9 +550,7 @@ def test_async_task_processing(distributed_client, added_flow, created_api_key):
# Test function without loop
@pytest.mark.async_test
def test_async_task_processing_vector_store(
client, added_vector_store, created_api_key
):
def test_async_task_processing_vector_store(client, added_vector_store, created_api_key):
headers = {"x-api-key": created_api_key.api_key}
post_data = {"inputs": {"input": "How do I upload examples?"}}
@ -594,6 +579,4 @@ def test_async_task_processing_vector_store(
# Validate that the task completed successfully and the result is as expected
assert "result" in task_status_json, task_status_json
assert "output" in task_status_json["result"], task_status_json["result"]
assert "Langflow" in task_status_json["result"]["output"], task_status_json[
"result"
]
assert "Langflow" in task_status_json["result"]["output"], task_status_json["result"]