[TEST] test_prompts.py

This commit is contained in:
Evgeny (Krymmy) Momotov 2025-09-25 13:49:27 +03:00
parent b333f7e83b
commit 44ac992795

56
tests/test_prompts.py Normal file
View file

@ -0,0 +1,56 @@
import asyncio
import pytest
from TaxisLibrary.taxis_client import TaxisClient, PromptIn, PromptOut, PromptFor
@pytest.fixture
def client():
client = TaxisClient("http://127.0.0.1:7000")
asyncio.run(client.login(username="root", password="12345"))
return client
class TestPrompts:
@pytest.mark.asyncio
async def test_create_prompt_taxi(self, client):
prompt = PromptIn(name="test_taxi", content="test", prompt_for=PromptFor.TAXI)
result = await client.create_prompt(prompt)
assert isinstance(result, PromptOut)
await client.delete_prompt(result.id)
@pytest.mark.asyncio
async def test_create_prompt_client(self, client):
prompt = PromptIn(name="test_client", content="test", prompt_for=PromptFor.CLIENT)
result = await client.create_prompt(prompt)
assert isinstance(result, PromptOut)
await client.delete_prompt(result.id)
@pytest.mark.asyncio
async def test_list_prompts(self, client):
result = await client.list_prompts()
assert isinstance(result, list)
if len(result) > 0:
assert all(isinstance(item, PromptOut) for item in result)
@pytest.mark.asyncio
async def test_get_prompt(self, client):
prompt = PromptIn(name="test_taxi", content="test", prompt_for=PromptFor.TAXI)
result = await client.create_prompt(prompt)
assert isinstance(result, PromptOut)
result = await client.get_prompt(result.id)
assert isinstance(result, PromptOut)
await client.delete_prompt(result.id)
@pytest.mark.asyncio
async def test_update_prompt(self, client):
prompt = PromptIn(name="test_taxi", content="test", prompt_for=PromptFor.TAXI)
result = await client.create_prompt(prompt)
assert isinstance(result, PromptOut)
result = await client.get_prompt(result.id)
assert isinstance(result, PromptOut)
prompt_data = PromptIn(name="test_taxi_update", content="test_update", prompt_for=PromptFor.TAXI)
result = await client.update_prompt(result.id, prompt_data)
assert isinstance(result, PromptOut)
await client.delete_prompt(result.id)