56 lines
No EOL
2.1 KiB
Python
56 lines
No EOL
2.1 KiB
Python
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) |