Refactor endpoints.py to improve code handling and remove caching (#2180)
* chore: Refactor CustomComponent to improve repr_value handling
* ♻️ (endpoints.py): Refactor the simplified_run_flow and webhook_run_flow functions to remove caching
* Refactor endpoints.py to remove caching and update tests
This commit is contained in:
parent
8e74b16e64
commit
c53901f7ef
4 changed files with 49 additions and 72 deletions
|
|
@ -701,36 +701,36 @@ def test_run_flow_with_caching_invalid_input_format(client: TestClient, starter_
|
|||
assert response.status_code == status.HTTP_422_UNPROCESSABLE_ENTITY
|
||||
|
||||
|
||||
@pytest.mark.api_key_required
|
||||
def test_run_flow_with_session_id(client, starter_project, created_api_key):
|
||||
headers = {"x-api-key": created_api_key.api_key}
|
||||
flow_id = starter_project["id"]
|
||||
payload = {
|
||||
"input_value": "value1",
|
||||
"input_type": "text",
|
||||
"output_type": "text",
|
||||
"session_id": "test-session-id",
|
||||
}
|
||||
response = client.post(f"/api/v1/run/{flow_id}", json=payload, headers=headers)
|
||||
assert response.status_code == status.HTTP_404_NOT_FOUND
|
||||
data = response.json()
|
||||
assert {"detail": "Session test-session-id not found"} == data
|
||||
# @pytest.mark.api_key_required
|
||||
# def test_run_flow_with_session_id(client, starter_project, created_api_key):
|
||||
# headers = {"x-api-key": created_api_key.api_key}
|
||||
# flow_id = starter_project["id"]
|
||||
# payload = {
|
||||
# "input_value": "value1",
|
||||
# "input_type": "text",
|
||||
# "output_type": "text",
|
||||
# "session_id": "test-session-id",
|
||||
# }
|
||||
# response = client.post(f"/api/v1/run/{flow_id}", json=payload, headers=headers)
|
||||
# assert response.status_code == status.HTTP_404_NOT_FOUND
|
||||
# data = response.json()
|
||||
# assert {"detail": "Session test-session-id not found"} == data
|
||||
|
||||
|
||||
def test_run_flow_with_invalid_session_id(client, starter_project, created_api_key):
|
||||
headers = {"x-api-key": created_api_key.api_key}
|
||||
flow_id = starter_project["id"]
|
||||
payload = {
|
||||
"input_value": "value1",
|
||||
"input_type": "text",
|
||||
"output_type": "text",
|
||||
"session_id": "invalid-session-id",
|
||||
}
|
||||
response = client.post(f"/api/v1/run/{flow_id}", json=payload, headers=headers)
|
||||
assert response.status_code == status.HTTP_404_NOT_FOUND
|
||||
data = response.json()
|
||||
assert "detail" in data
|
||||
assert f"Session {payload['session_id']} not found" in data["detail"]
|
||||
# def test_run_flow_with_invalid_session_id(client, starter_project, created_api_key):
|
||||
# headers = {"x-api-key": created_api_key.api_key}
|
||||
# flow_id = starter_project["id"]
|
||||
# payload = {
|
||||
# "input_value": "value1",
|
||||
# "input_type": "text",
|
||||
# "output_type": "text",
|
||||
# "session_id": "invalid-session-id",
|
||||
# }
|
||||
# response = client.post(f"/api/v1/run/{flow_id}", json=payload, headers=headers)
|
||||
# assert response.status_code == status.HTTP_404_NOT_FOUND
|
||||
# data = response.json()
|
||||
# assert "detail" in data
|
||||
# assert f"Session {payload['session_id']} not found" in data["detail"]
|
||||
|
||||
|
||||
@pytest.mark.api_key_required
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue