diff --git a/tests/test_prompts.py b/tests/test_prompts.py new file mode 100644 index 0000000..b650808 --- /dev/null +++ b/tests/test_prompts.py @@ -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) \ No newline at end of file