[TEST] test_prompts.py
This commit is contained in:
parent
b333f7e83b
commit
44ac992795
1 changed files with 56 additions and 0 deletions
56
tests/test_prompts.py
Normal file
56
tests/test_prompts.py
Normal 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)
|
||||
Loading…
Add table
Reference in a new issue