langflow/tests/test_prompts_template.py
Gabriel Luiz Freitas Almeida 94d598b59c 🔧 fix(test_endpoints.py): fix import statement for TimeTravelGuideChainNode
🔧 fix(test_endpoints.py): update test_get_all to assert "PromptTemplate" instead of "ZeroShotPrompt"
🔧 fix(test_endpoints.py): update test_valid_prompt and test_invalid_prompt to use PROMPT_REQUEST variable
🔧 fix(test_endpoints.py): update test_various_prompts to use PROMPT_REQUEST variable
🔧 fix(test_prompts_template.py): remove test_zero_shot_prompt as it is no longer needed
The import statement for TimeTravelGuideChainNode is fixed to ensure the correct module is imported. The test_get_all function is updated to assert the presence of "PromptTemplate" instead of "ZeroShotPrompt" in the response. The test_valid_prompt, test_invalid_prompt, and test_various_prompts functions are updated to use the PROMPT_REQUEST variable for the request payload. The test_zero_shot_prompt function is removed as it is no longer needed.
2023-07-07 18:25:57 -03:00

94 lines
2.5 KiB
Python

from fastapi.testclient import TestClient
from langflow.settings import settings
def test_prompts_settings(client: TestClient):
response = client.get("api/v1/all")
assert response.status_code == 200
json_response = response.json()
prompts = json_response["prompts"]
assert set(prompts.keys()) == set(settings.prompts)
def test_prompt_template(client: TestClient):
response = client.get("api/v1/all")
assert response.status_code == 200
json_response = response.json()
prompts = json_response["prompts"]
prompt = prompts["PromptTemplate"]
template = prompt["template"]
assert template["input_variables"] == {
"required": True,
"placeholder": "",
"show": False,
"multiline": False,
"password": False,
"name": "input_variables",
"type": "str",
"list": True,
"advanced": False,
"info": "",
}
assert template["output_parser"] == {
"required": False,
"placeholder": "",
"show": False,
"multiline": False,
"password": False,
"name": "output_parser",
"type": "BaseOutputParser",
"list": False,
"advanced": False,
"info": "",
}
assert template["partial_variables"] == {
"required": False,
"placeholder": "",
"show": False,
"multiline": False,
"password": False,
"name": "partial_variables",
"type": "code",
"list": False,
"advanced": False,
"info": "",
}
assert template["template"] == {
"required": True,
"placeholder": "",
"show": True,
"multiline": True,
"password": False,
"name": "template",
"type": "prompt",
"list": False,
"advanced": False,
"info": "",
}
assert template["template_format"] == {
"required": False,
"placeholder": "",
"show": False,
"multiline": False,
"value": "f-string",
"password": False,
"name": "template_format",
"type": "str",
"list": False,
"advanced": False,
"info": "",
}
assert template["validate_template"] == {
"required": False,
"placeholder": "",
"show": False,
"multiline": False,
"value": True,
"password": False,
"name": "validate_template",
"type": "bool",
"list": False,
"advanced": False,
"info": "",
}