diff --git a/tests/test_audio_rooms.py b/tests/test_audio_rooms.py index 9198d2c..e8619be 100644 --- a/tests/test_audio_rooms.py +++ b/tests/test_audio_rooms.py @@ -1,7 +1,7 @@ import httpx import pytest -from cozepy import AsyncCoze, Coze, CreateRoomResp, TokenAuth +from cozepy import AsyncCoze, AsyncTokenAuth, Coze, CreateRoomResp, TokenAuth from cozepy.util import random_hex from tests.test_util import logid_key @@ -45,7 +45,7 @@ def test_sync_rooms_create(self, respx_mock): @pytest.mark.asyncio class TestAsyncAudioRooms: async def test_async_rooms_create(self, respx_mock): - coze = AsyncCoze(auth=TokenAuth(token="token")) + coze = AsyncCoze(auth=AsyncTokenAuth(token="token")) bot_id = random_hex(10) voice_id = random_hex(10) diff --git a/tests/test_audio_speech.py b/tests/test_audio_speech.py index 1aef630..cf248e7 100644 --- a/tests/test_audio_speech.py +++ b/tests/test_audio_speech.py @@ -1,7 +1,7 @@ import httpx import pytest -from cozepy import AsyncCoze, Coze, TokenAuth +from cozepy import AsyncCoze, AsyncTokenAuth, Coze, TokenAuth from cozepy.util import random_hex from tests.test_util import logid_key @@ -39,7 +39,7 @@ def test_sync_speech_create(self, respx_mock): @pytest.mark.asyncio class TestAsyncAudioSpeech: async def test_async_speech_create(self, respx_mock): - coze = AsyncCoze(auth=TokenAuth(token="token")) + coze = AsyncCoze(auth=AsyncTokenAuth(token="token")) mock_logid = mock_create_speech(respx_mock) diff --git a/tests/test_audio_translations.py b/tests/test_audio_translations.py index b494cb5..afd386e 100644 --- a/tests/test_audio_translations.py +++ b/tests/test_audio_translations.py @@ -1,7 +1,7 @@ import httpx import pytest -from cozepy import AsyncCoze, Coze, TokenAuth +from cozepy import AsyncCoze, AsyncTokenAuth, Coze, TokenAuth from cozepy.util import random_hex from tests.test_util import logid_key @@ -41,7 +41,7 @@ def test_sync_transcriptions_create(self, respx_mock): @pytest.mark.asyncio class TestAsyncAudioTranscriptions: async def test_async_transcriptions_create(self, respx_mock): - coze = AsyncCoze(auth=TokenAuth(token="token")) + coze = AsyncCoze(auth=AsyncTokenAuth(token="token")) mock_logid = mock_create_transcriptions(respx_mock) diff --git a/tests/test_audio_voices.py b/tests/test_audio_voices.py index 3746b71..26234fb 100644 --- a/tests/test_audio_voices.py +++ b/tests/test_audio_voices.py @@ -3,7 +3,7 @@ import httpx import pytest -from cozepy import AsyncCoze, AudioFormat, Coze, TokenAuth, Voice +from cozepy import AsyncCoze, AsyncTokenAuth, AudioFormat, Coze, TokenAuth, Voice from cozepy.util import random_hex from tests.test_util import logid_key @@ -88,7 +88,7 @@ def test_clone_voice(self, respx_mock): @pytest.mark.asyncio class TestAsyncAudioVoices: async def test_async_voices_list(self, respx_mock): - coze = AsyncCoze(auth=TokenAuth(token="token")) + coze = AsyncCoze(auth=AsyncTokenAuth(token="token")) mock_logid = mock_list_voices(respx_mock) @@ -100,7 +100,7 @@ async def test_async_voices_list(self, respx_mock): assert len(voices) == 1 async def test_async_clone_voice(self, respx_mock): - coze = AsyncCoze(auth=TokenAuth(token="token")) + coze = AsyncCoze(auth=AsyncTokenAuth(token="token")) mock_voice = mock_clone_voice(respx_mock) diff --git a/tests/test_bots.py b/tests/test_bots.py index 222f475..abbfce9 100644 --- a/tests/test_bots.py +++ b/tests/test_bots.py @@ -1,7 +1,7 @@ import httpx import pytest -from cozepy import AsyncCoze, Bot, Coze, SimpleBot, TokenAuth +from cozepy import AsyncCoze, AsyncTokenAuth, Bot, Coze, SimpleBot, TokenAuth from cozepy.util import random_hex from tests.test_util import logid_key @@ -189,7 +189,7 @@ def test_sync_bots_list(self, respx_mock): @pytest.mark.asyncio class TestAsyncBots: async def test_async_bots_create(self, respx_mock): - coze = AsyncCoze(auth=TokenAuth(token="token")) + coze = AsyncCoze(auth=AsyncTokenAuth(token="token")) mock_bot = mock_create_bot(respx_mock) @@ -200,7 +200,7 @@ async def test_async_bots_create(self, respx_mock): assert bot.bot_id == mock_bot.bot_id async def test_async_bots_update(self, respx_mock): - coze = AsyncCoze(auth=TokenAuth(token="token")) + coze = AsyncCoze(auth=AsyncTokenAuth(token="token")) mock_logid = mock_update_bot(respx_mock) @@ -210,7 +210,7 @@ async def test_async_bots_update(self, respx_mock): assert res.response.logid == mock_logid async def test_async_bots_publish(self, respx_mock): - coze = AsyncCoze(auth=TokenAuth(token="token")) + coze = AsyncCoze(auth=AsyncTokenAuth(token="token")) mock_bot = mock_publish_bot(respx_mock) @@ -221,7 +221,7 @@ async def test_async_bots_publish(self, respx_mock): assert bot.bot_id == mock_bot.bot_id async def test_async_bots_retrieve(self, respx_mock): - coze = AsyncCoze(auth=TokenAuth(token="token")) + coze = AsyncCoze(auth=AsyncTokenAuth(token="token")) mock_bot = mock_retrieve_bot(respx_mock) @@ -232,7 +232,7 @@ async def test_async_bots_retrieve(self, respx_mock): assert bot.bot_id == mock_bot.bot_id async def test_async_bots_list(self, respx_mock): - coze = AsyncCoze(auth=TokenAuth(token="token")) + coze = AsyncCoze(auth=AsyncTokenAuth(token="token")) space_id = random_hex(10) total = 10 diff --git a/tests/test_chat.py b/tests/test_chat.py index 14a4137..b621366 100644 --- a/tests/test_chat.py +++ b/tests/test_chat.py @@ -7,6 +7,7 @@ from cozepy import ( AsyncCoze, + AsyncTokenAuth, Chat, ChatError, ChatEvent, @@ -357,7 +358,7 @@ def test_sync_chat_poll(self, respx_mock): @pytest.mark.asyncio class TestAsyncChatConversationMessage: async def test_async_chat_create(self, respx_mock): - coze = AsyncCoze(auth=TokenAuth(token="token")) + coze = AsyncCoze(auth=AsyncTokenAuth(token="token")) conversation_id = "conversation_id" mock_logid = mock_chat_create(respx_mock, conversation_id, ChatStatus.FAILED) @@ -369,7 +370,7 @@ async def test_async_chat_create(self, respx_mock): assert res.conversation_id == conversation_id async def test_async_chat_stream(self, respx_mock): - coze = AsyncCoze(auth=TokenAuth(token="token")) + coze = AsyncCoze(auth=AsyncTokenAuth(token="token")) mock_chat_stream(respx_mock, read_file("testdata/chat_text_stream_resp.txt")) stream = coze.chat.stream(bot_id="bot", user_id="user") @@ -399,7 +400,7 @@ async def test_async_chat_stream(self, respx_mock): assert events[len(events) - 1].event == ChatEventType.CONVERSATION_CHAT_COMPLETED async def test_async_chat_audio_stream(self, respx_mock): - coze = AsyncCoze(auth=TokenAuth(token="token")) + coze = AsyncCoze(auth=AsyncTokenAuth(token="token")) mock_logid = mock_chat_stream(respx_mock, read_file("testdata/chat_audio_stream_resp.txt")) # noqa: F841 stream = coze.chat.stream( @@ -424,7 +425,7 @@ async def test_async_chat_audio_stream(self, respx_mock): assert os.path.exists(temp_filename) async def test_async_chat_stream_error(self, respx_mock): - coze = AsyncCoze(auth=TokenAuth(token="token")) + coze = AsyncCoze(auth=AsyncTokenAuth(token="token")) mock_logid = mock_chat_stream(respx_mock, read_file("testdata/chat_error_resp.txt")) # noqa: F841 stream = coze.chat.stream(bot_id="bot", user_id="user") @@ -433,7 +434,7 @@ async def test_async_chat_stream_error(self, respx_mock): [event async for event in stream] async def test_async_chat_stream_failed(self, respx_mock): - coze = AsyncCoze(auth=TokenAuth(token="token")) + coze = AsyncCoze(auth=AsyncTokenAuth(token="token")) mock_logid = mock_chat_stream(respx_mock, read_file("testdata/chat_failed_resp.txt")) # noqa: F841 stream = coze.chat.stream(bot_id="bot", user_id="user") @@ -444,7 +445,7 @@ async def test_async_chat_stream_failed(self, respx_mock): assert events[0].chat.last_error.code == 5000 async def test_async_chat_stream_invalid_event(self, respx_mock): - coze = AsyncCoze(auth=TokenAuth(token="token")) + coze = AsyncCoze(auth=AsyncTokenAuth(token="token")) mock_logid = mock_chat_stream(respx_mock, read_file("testdata/chat_invalid_resp.txt")) # noqa: F841 @@ -454,7 +455,7 @@ async def test_async_chat_stream_invalid_event(self, respx_mock): [event async for event in stream] async def test_async_chat_retrieve(self, respx_mock): - coze = AsyncCoze(auth=TokenAuth(token="token")) + coze = AsyncCoze(auth=AsyncTokenAuth(token="token")) conversation_id = "conversation_id" mock_logid = mock_chat_retrieve(respx_mock, conversation_id, ChatStatus.FAILED) @@ -466,7 +467,7 @@ async def test_async_chat_retrieve(self, respx_mock): assert res.conversation_id == conversation_id async def test_async_submit_tool_outputs_not_stream(self, respx_mock): - coze = AsyncCoze(auth=TokenAuth(token="token")) + coze = AsyncCoze(auth=AsyncTokenAuth(token="token")) conversation_id = "conversation_id" mock_logid = mock_chat_submit_tool_outputs(respx_mock, conversation_id, ChatStatus.FAILED) @@ -478,7 +479,7 @@ async def test_async_submit_tool_outputs_not_stream(self, respx_mock): assert res.conversation_id == conversation_id async def test_async_submit_tool_outputs_stream(self, respx_mock): - coze = AsyncCoze(auth=TokenAuth(token="token")) + coze = AsyncCoze(auth=AsyncTokenAuth(token="token")) mock_chat_submit_tool_outputs_stream(respx_mock, read_file("testdata/chat_text_stream_resp.txt")) stream = coze.chat.submit_tool_outputs_stream(conversation_id="conversation", chat_id="chat", tool_outputs=[]) @@ -508,7 +509,7 @@ async def test_async_submit_tool_outputs_stream(self, respx_mock): assert events[len(events) - 1].event == ChatEventType.CONVERSATION_CHAT_COMPLETED async def test_async_chat_cancel(self, respx_mock): - coze = AsyncCoze(auth=TokenAuth(token="token")) + coze = AsyncCoze(auth=AsyncTokenAuth(token="token")) conversation_id = "conversation_id" mock_logid = mock_chat_cancel(respx_mock, conversation_id, ChatStatus.FAILED) diff --git a/tests/test_chat_messages.py b/tests/test_chat_messages.py index 3bc7dea..a57fd06 100644 --- a/tests/test_chat_messages.py +++ b/tests/test_chat_messages.py @@ -1,7 +1,7 @@ import httpx import pytest -from cozepy import AsyncCoze, Coze, Message, TokenAuth +from cozepy import AsyncCoze, AsyncTokenAuth, Coze, Message, TokenAuth from cozepy.util import random_hex from tests.test_util import logid_key @@ -39,7 +39,7 @@ def test_sync_chat_messages_list(self, respx_mock): @pytest.mark.asyncio class TestAsyncChatMessages: async def test_async_chat_messages_list(self, respx_mock): - coze = AsyncCoze(auth=TokenAuth(token="token")) + coze = AsyncCoze(auth=AsyncTokenAuth(token="token")) msg, msg2, logid = mock_chat_messages_list(respx_mock) diff --git a/tests/test_conversations.py b/tests/test_conversations.py index 53437b7..0a73d4d 100644 --- a/tests/test_conversations.py +++ b/tests/test_conversations.py @@ -3,7 +3,7 @@ import httpx import pytest -from cozepy import AsyncCoze, Conversation, Coze, Section, TokenAuth +from cozepy import AsyncCoze, AsyncTokenAuth, Conversation, Coze, Section, TokenAuth from cozepy.util import random_hex from tests.test_util import logid_key @@ -152,7 +152,7 @@ def test_sync_conversations_clear(self, respx_mock): @pytest.mark.asyncio class TestAsyncConversation: async def test_async_conversations_create(self, respx_mock): - coze = AsyncCoze(auth=TokenAuth(token="token")) + coze = AsyncCoze(auth=AsyncTokenAuth(token="token")) bot_id = random_hex(10) mock_conversation = mock_create_conversations(respx_mock) @@ -164,7 +164,7 @@ async def test_async_conversations_create(self, respx_mock): assert res.last_section_id == mock_conversation.last_section_id async def test_async_conversations_list(self, respx_mock): - coze = AsyncCoze(auth=TokenAuth(token="token")) + coze = AsyncCoze(auth=AsyncTokenAuth(token="token")) total = 10 size = 1 @@ -196,7 +196,7 @@ async def test_async_conversations_list(self, respx_mock): assert total_result == total async def test_async_conversations_retrieve(self, respx_mock): - coze = AsyncCoze(auth=TokenAuth(token="token")) + coze = AsyncCoze(auth=AsyncTokenAuth(token="token")) mock_conversation = mock_retrieve_conversation(respx_mock) @@ -207,7 +207,7 @@ async def test_async_conversations_retrieve(self, respx_mock): assert res.last_section_id == mock_conversation.last_section_id async def test_async_conversations_clear(self, respx_mock): - coze = AsyncCoze(auth=TokenAuth(token="token")) + coze = AsyncCoze(auth=AsyncTokenAuth(token="token")) mock_section = mock_clear_conversation(respx_mock) diff --git a/tests/test_conversations_messages.py b/tests/test_conversations_messages.py index 2922255..5fe4e60 100644 --- a/tests/test_conversations_messages.py +++ b/tests/test_conversations_messages.py @@ -1,7 +1,7 @@ import httpx import pytest -from cozepy import AsyncCoze, Coze, Message, TokenAuth +from cozepy import AsyncCoze, AsyncTokenAuth, Coze, Message, TokenAuth from cozepy.util import random_hex from tests.test_util import logid_key @@ -159,7 +159,7 @@ def test_sync_conversations_messages_delete(self, respx_mock): @pytest.mark.asyncio class TestAsyncConversationMessage: async def test_async_conversations_messages_create(self, respx_mock): - coze = AsyncCoze(auth=TokenAuth(token="token")) + coze = AsyncCoze(auth=AsyncTokenAuth(token="token")) mock_msg = mock_create_conversations_messages(respx_mock, Message.build_assistant_answer("hi")) @@ -174,7 +174,7 @@ async def test_async_conversations_messages_create(self, respx_mock): assert message.content == mock_msg.content async def test_async_conversations_messages_list(self, respx_mock): - coze = AsyncCoze(auth=TokenAuth(token="token")) + coze = AsyncCoze(auth=AsyncTokenAuth(token="token")) total = 10 size = 1 @@ -206,7 +206,7 @@ async def test_async_conversations_messages_list(self, respx_mock): assert total_result == total async def test_async_conversations_messages_retrieve(self, respx_mock): - coze = AsyncCoze(auth=TokenAuth(token="token")) + coze = AsyncCoze(auth=AsyncTokenAuth(token="token")) mock_msg = mock_retrieve_conversations_messages(respx_mock, Message.build_user_question_text("hi")) @@ -216,7 +216,7 @@ async def test_async_conversations_messages_retrieve(self, respx_mock): assert message.content == mock_msg.content async def test_async_conversations_messages_update(self, respx_mock): - coze = AsyncCoze(auth=TokenAuth(token="token")) + coze = AsyncCoze(auth=AsyncTokenAuth(token="token")) mock_msg = mock_update_conversations_messages(respx_mock, Message.build_user_question_text("hi")) message = await coze.conversations.messages.update(conversation_id="conversation id", message_id="message id") @@ -225,7 +225,7 @@ async def test_async_conversations_messages_update(self, respx_mock): assert message.content == mock_msg.content async def test_async_conversations_messages_delete(self, respx_mock): - coze = AsyncCoze(auth=TokenAuth(token="token")) + coze = AsyncCoze(auth=AsyncTokenAuth(token="token")) mock_msg = mock_delete_conversations_messages(respx_mock, Message.build_user_question_text("hi")) diff --git a/tests/test_datasets.py b/tests/test_datasets.py index 09be4c5..bff8f94 100644 --- a/tests/test_datasets.py +++ b/tests/test_datasets.py @@ -1,7 +1,7 @@ import httpx import pytest -from cozepy import AsyncCoze, Coze, TokenAuth +from cozepy import AsyncCoze, AsyncTokenAuth, Coze, TokenAuth from cozepy.datasets import Dataset, DatasetStatus, DocumentFormatType, DocumentProgress from cozepy.datasets.documents import DocumentStatus, DocumentUpdateType from cozepy.util import random_hex @@ -182,7 +182,7 @@ def test_sync_datasets_process(self, respx_mock): @pytest.mark.asyncio class TestAsyncDataset: async def test_async_datasets_create(self, respx_mock): - coze = AsyncCoze(auth=TokenAuth(token="token")) + coze = AsyncCoze(auth=AsyncTokenAuth(token="token")) dataset_id, mock_logid = mock_create_datasets(respx_mock) @@ -192,7 +192,7 @@ async def test_async_datasets_create(self, respx_mock): assert dataset.dataset_id == dataset_id async def test_async_datasets_list(self, respx_mock): - coze = AsyncCoze(auth=TokenAuth(token="token")) + coze = AsyncCoze(auth=AsyncTokenAuth(token="token")) space_id = random_hex(10) total = 10 @@ -225,7 +225,7 @@ async def test_async_datasets_list(self, respx_mock): assert total_result == total async def test_async_datasets_update(self, respx_mock): - coze = AsyncCoze(auth=TokenAuth(token="token")) + coze = AsyncCoze(auth=AsyncTokenAuth(token="token")) dataset_id, mock_logid = mock_update_datasets(respx_mock) @@ -234,7 +234,7 @@ async def test_async_datasets_update(self, respx_mock): assert res.response.logid == mock_logid async def test_async_datasets_delete(self, respx_mock): - coze = AsyncCoze(auth=TokenAuth(token="token")) + coze = AsyncCoze(auth=AsyncTokenAuth(token="token")) dataset_id, mock_logid = mock_delete_datasets(respx_mock) @@ -243,7 +243,7 @@ async def test_async_datasets_delete(self, respx_mock): assert res.response.logid == mock_logid async def test_async_datasets_process(self, respx_mock): - coze = AsyncCoze(auth=TokenAuth(token="token")) + coze = AsyncCoze(auth=AsyncTokenAuth(token="token")) dataset_id, document_id, mock_logid = mock_process_datasets(respx_mock) diff --git a/tests/test_datasets_documents.py b/tests/test_datasets_documents.py index 33ed206..859f23e 100644 --- a/tests/test_datasets_documents.py +++ b/tests/test_datasets_documents.py @@ -5,6 +5,7 @@ from cozepy import ( AsyncCoze, + AsyncTokenAuth, Coze, Document, DocumentBase, @@ -200,7 +201,7 @@ def test_sync_datasets_documents_list(self, respx_mock): @pytest.mark.asyncio class TestAsyncDatasetsDocuments: async def test_async_datasets_documents_create_web_auto_update(self, respx_mock): - coze = AsyncCoze(auth=TokenAuth(token="token")) + coze = AsyncCoze(auth=AsyncTokenAuth(token="token")) mock_document = mock_create_datasets_documents(respx_mock) @@ -220,7 +221,7 @@ async def test_async_datasets_documents_create_web_auto_update(self, respx_mock) assert len(documents) == 1 async def test_async_datasets_documents_create_local_custom(self, respx_mock): - coze = AsyncCoze(auth=TokenAuth(token="token")) + coze = AsyncCoze(auth=AsyncTokenAuth(token="token")) mock_document = mock_create_datasets_documents(respx_mock) @@ -240,7 +241,7 @@ async def test_async_datasets_documents_create_local_custom(self, respx_mock): assert len(documents) == 1 async def test_async_datasets_documents_update(self, respx_mock): - coze = AsyncCoze(auth=TokenAuth(token="token")) + coze = AsyncCoze(auth=AsyncTokenAuth(token="token")) mock_document = mock_update_datasets_documents(respx_mock) @@ -249,7 +250,7 @@ async def test_async_datasets_documents_update(self, respx_mock): assert res.response.logid == mock_document.response.logid async def test_async_datasets_documents_delete(self, respx_mock): - coze = AsyncCoze(auth=TokenAuth(token="token")) + coze = AsyncCoze(auth=AsyncTokenAuth(token="token")) mock_document = mock_delete_datasets_documents(respx_mock) @@ -258,7 +259,7 @@ async def test_async_datasets_documents_delete(self, respx_mock): assert res.response.logid == mock_document.response.logid async def test_async_datasets_documents_list(self, respx_mock): - coze = AsyncCoze(auth=TokenAuth(token="token")) + coze = AsyncCoze(auth=AsyncTokenAuth(token="token")) total = 10 size = 1 diff --git a/tests/test_datasets_images.py b/tests/test_datasets_images.py index 58708a0..514406a 100644 --- a/tests/test_datasets_images.py +++ b/tests/test_datasets_images.py @@ -3,6 +3,7 @@ from cozepy import ( AsyncCoze, + AsyncTokenAuth, Coze, TokenAuth, ) @@ -101,7 +102,7 @@ def test_sync_datasets_images_list(self, respx_mock): @pytest.mark.asyncio class TestAsyncDatasetsDocuments: async def test_sync_datasets_images_update(self, respx_mock): - coze = AsyncCoze(auth=TokenAuth(token="token")) + coze = AsyncCoze(auth=AsyncTokenAuth(token="token")) dataset_id, document_id, mock_logid = mock_update_datasets_images(respx_mock) @@ -110,7 +111,7 @@ async def test_sync_datasets_images_update(self, respx_mock): assert res.response.logid == mock_logid async def test_sync_datasets_images_list(self, respx_mock): - coze = AsyncCoze(auth=TokenAuth(token="token")) + coze = AsyncCoze(auth=AsyncTokenAuth(token="token")) dataset_id = random_hex(10) total = 10 diff --git a/tests/test_file.py b/tests/test_file.py index 5889f42..7eaa000 100644 --- a/tests/test_file.py +++ b/tests/test_file.py @@ -4,7 +4,7 @@ import httpx import pytest -from cozepy import AsyncCoze, Coze, File, TokenAuth +from cozepy import AsyncCoze, AsyncTokenAuth, Coze, File, TokenAuth from cozepy.files import _try_fix_file from cozepy.util import random_hex from tests.test_util import logid_key @@ -70,7 +70,7 @@ def test_sync_files_retrieve(self, respx_mock): @pytest.mark.asyncio class TestAsyncFiles: async def test_async_files_upload(self, respx_mock): - coze = AsyncCoze(auth=TokenAuth(token="token")) + coze = AsyncCoze(auth=AsyncTokenAuth(token="token")) mock_file = mock_upload_files(respx_mock) @@ -81,7 +81,7 @@ async def test_async_files_upload(self, respx_mock): assert file.file_name == "name" async def test_async_files_retrieve(self, respx_mock): - coze = AsyncCoze(auth=TokenAuth(token="token")) + coze = AsyncCoze(auth=AsyncTokenAuth(token="token")) mock_file = mock_retrieve_files(respx_mock) diff --git a/tests/test_knowledge_documents.py b/tests/test_knowledge_documents.py index 253a97a..32b7785 100644 --- a/tests/test_knowledge_documents.py +++ b/tests/test_knowledge_documents.py @@ -5,6 +5,7 @@ from cozepy import ( AsyncCoze, + AsyncTokenAuth, Coze, Document, DocumentBase, @@ -223,7 +224,7 @@ def test_sync_knowledge_documents_page_iterator(self, respx_mock): @pytest.mark.asyncio class TestAsyncKnowledgeDocuments: async def test_sync_knowledge_documents_create_web_auto_update(self, respx_mock): - coze = AsyncCoze(auth=TokenAuth(token="token")) + coze = AsyncCoze(auth=AsyncTokenAuth(token="token")) respx_mock.post("/open_api/knowledge/document/create").mock( httpx.Response( @@ -247,7 +248,7 @@ async def test_sync_knowledge_documents_create_web_auto_update(self, respx_mock) assert len(documents) == 1 async def test_sync_knowledge_documents_create_local_custom(self, respx_mock): - coze = AsyncCoze(auth=TokenAuth(token="token")) + coze = AsyncCoze(auth=AsyncTokenAuth(token="token")) respx_mock.post("/open_api/knowledge/document/create").mock( httpx.Response( @@ -271,21 +272,21 @@ async def test_sync_knowledge_documents_create_local_custom(self, respx_mock): assert len(documents) == 1 async def test_sync_knowledge_documents_update(self, respx_mock): - coze = AsyncCoze(auth=TokenAuth(token="token")) + coze = AsyncCoze(auth=AsyncTokenAuth(token="token")) respx_mock.post("/open_api/knowledge/document/update").mock(httpx.Response(200, json={"data": None})) await coze.knowledge.documents.update(document_id="id", document_name="name") async def test_sync_knowledge_documents_delete(self, respx_mock): - coze = AsyncCoze(auth=TokenAuth(token="token")) + coze = AsyncCoze(auth=AsyncTokenAuth(token="token")) respx_mock.post("/open_api/knowledge/document/delete").mock(httpx.Response(200, json={"data": None})) await coze.knowledge.documents.delete(document_ids=["id"]) async def test_sync_knowledge_documents_list(self, respx_mock): - coze = AsyncCoze(auth=TokenAuth(token="token")) + coze = AsyncCoze(auth=AsyncTokenAuth(token="token")) total = 10 mock_documents_list(respx_mock, total, 1) @@ -295,7 +296,7 @@ async def test_sync_knowledge_documents_list(self, respx_mock): assert resp.total == total async def test_async_knowledge_documents_iterator(self, respx_mock): - coze = AsyncCoze(auth=TokenAuth(token="token")) + coze = AsyncCoze(auth=AsyncTokenAuth(token="token")) total = 10 for idx in range(total): @@ -311,7 +312,7 @@ async def test_async_knowledge_documents_iterator(self, respx_mock): assert total_result == total async def test_async_knowledge_documents_page_iterator(self, respx_mock): - coze = AsyncCoze(auth=TokenAuth(token="token")) + coze = AsyncCoze(auth=AsyncTokenAuth(token="token")) total = 10 for idx in range(total): diff --git a/tests/test_template.py b/tests/test_template.py index 635d5f8..aae0f26 100644 --- a/tests/test_template.py +++ b/tests/test_template.py @@ -1,7 +1,7 @@ import httpx import pytest -from cozepy import AsyncCoze, Coze, TemplateDuplicateResp, TokenAuth +from cozepy import AsyncCoze, AsyncTokenAuth, Coze, TemplateDuplicateResp, TokenAuth from cozepy.util import random_hex @@ -39,7 +39,7 @@ def test_sync_template_duplicate(self, respx_mock): @pytest.mark.asyncio class TestAsyncTemplate: async def test_async_template_duplicate(self, respx_mock): - coze = AsyncCoze(auth=TokenAuth(token="token")) + coze = AsyncCoze(auth=AsyncTokenAuth(token="token")) entity_id = random_hex(10) entity_type = "agent" diff --git a/tests/test_users.py b/tests/test_users.py index 288fcf5..a383e17 100644 --- a/tests/test_users.py +++ b/tests/test_users.py @@ -1,7 +1,7 @@ import httpx import pytest -from cozepy import AsyncCoze, Coze, TokenAuth, User +from cozepy import AsyncCoze, AsyncTokenAuth, Coze, TokenAuth, User from cozepy.util import random_hex from tests.test_util import logid_key @@ -41,7 +41,7 @@ def test_sync_users_retrieve_me(self, respx_mock): @pytest.mark.asyncio class TestAsyncUsers: async def test_async_users_retrieve_me(self, respx_mock): - coze = AsyncCoze(auth=TokenAuth(token="token")) + coze = AsyncCoze(auth=AsyncTokenAuth(token="token")) mock_user = mock_retrieve_users_me(respx_mock) diff --git a/tests/test_workflows.py b/tests/test_workflows.py index ef26b9a..854d62a 100644 --- a/tests/test_workflows.py +++ b/tests/test_workflows.py @@ -3,6 +3,7 @@ from cozepy import ( AsyncCoze, + AsyncTokenAuth, Coze, TokenAuth, WorkflowExecuteStatus, @@ -166,7 +167,7 @@ def test_sync_workflows_runs_run_histories_retrieve(self, respx_mock): @pytest.mark.asyncio class TestAsyncWorkflowsRuns: async def test_async_workflows_runs_create_no_async(self, respx_mock): - coze = AsyncCoze(auth=TokenAuth(token="token")) + coze = AsyncCoze(auth=AsyncTokenAuth(token="token")) mock_res = mock_create_workflows_runs(respx_mock, False) @@ -176,7 +177,7 @@ async def test_async_workflows_runs_create_no_async(self, respx_mock): assert res.data == "data" async def test_async_workflows_runs_create_async(self, respx_mock): - coze = AsyncCoze(auth=TokenAuth(token="token")) + coze = AsyncCoze(auth=AsyncTokenAuth(token="token")) mock_res = mock_create_workflows_runs(respx_mock, True) @@ -187,7 +188,7 @@ async def test_async_workflows_runs_create_async(self, respx_mock): assert res.execute_id == mock_res.execute_id async def test_async_workflows_runs_stream(self, respx_mock): - coze = AsyncCoze(auth=TokenAuth(token="token")) + coze = AsyncCoze(auth=AsyncTokenAuth(token="token")) mock_create_workflows_runs_stream(respx_mock, read_file("testdata/workflow_run_stream_resp.txt")) stream = coze.workflows.runs.stream(workflow_id="id") @@ -196,7 +197,7 @@ async def test_async_workflows_runs_stream(self, respx_mock): assert len(events) == 9 async def test_async_workflows_runs_resume(self, respx_mock): - coze = AsyncCoze(auth=TokenAuth(token="token")) + coze = AsyncCoze(auth=AsyncTokenAuth(token="token")) mock_create_workflows_runs_resume(respx_mock, read_file("testdata/workflow_run_stream_resp.txt")) stream = coze.workflows.runs.resume( @@ -210,7 +211,7 @@ async def test_async_workflows_runs_resume(self, respx_mock): assert len(events) == 9 async def test_async_workflows_runs_invalid_stream_event(self, respx_mock): - coze = AsyncCoze(auth=TokenAuth(token="token")) + coze = AsyncCoze(auth=AsyncTokenAuth(token="token")) mock_create_workflows_runs_resume(respx_mock, read_file("testdata/workflow_run_invalid_stream_resp.txt")) stream = coze.workflows.runs.resume( @@ -223,7 +224,7 @@ async def test_async_workflows_runs_invalid_stream_event(self, respx_mock): [event async for event in stream] async def test_async_workflows_runs_run_histories_retrieve(self, respx_mock): - coze = AsyncCoze(auth=TokenAuth(token="token")) + coze = AsyncCoze(auth=AsyncTokenAuth(token="token")) workflow_id, execute_id, current_logid, execute_logid = mock_create_workflows_runs_run_histories_retrieve( respx_mock diff --git a/tests/test_workflows_chat.py b/tests/test_workflows_chat.py index 5a87579..7729d73 100644 --- a/tests/test_workflows_chat.py +++ b/tests/test_workflows_chat.py @@ -3,6 +3,7 @@ from cozepy import ( AsyncCoze, + AsyncTokenAuth, Chat, ChatError, ChatEvent, @@ -118,7 +119,7 @@ def test_sync_chat_stream_invalid_event(self, respx_mock): @pytest.mark.asyncio class TestAsyncWorkflowsChat: async def test_async_workflows_chat_stream(self, respx_mock): - coze = AsyncCoze(auth=TokenAuth(token="token")) + coze = AsyncCoze(auth=AsyncTokenAuth(token="token")) mock_workflows_chat_stream(respx_mock, read_file("testdata/workflows_chat_stream_resp.txt")) stream = coze.workflows.chat.stream(workflow_id="workflow", bot_id="bot") @@ -147,7 +148,7 @@ async def test_async_workflows_chat_stream(self, respx_mock): assert events[len(events) - 1].event == ChatEventType.CONVERSATION_CHAT_COMPLETED async def test_async_chat_stream_error(self, respx_mock): - coze = AsyncCoze(auth=TokenAuth(token="token")) + coze = AsyncCoze(auth=AsyncTokenAuth(token="token")) mock_workflows_chat_stream(respx_mock, read_file("testdata/chat_error_resp.txt")) stream = coze.workflows.chat.stream(workflow_id="workflow", bot_id="bot") @@ -157,7 +158,7 @@ async def test_async_chat_stream_error(self, respx_mock): _ = [event async for event in stream] async def test_async_chat_stream_failed(self, respx_mock): - coze = AsyncCoze(auth=TokenAuth(token="token")) + coze = AsyncCoze(auth=AsyncTokenAuth(token="token")) mock_workflows_chat_stream(respx_mock, read_file("testdata/chat_failed_resp.txt")) stream = coze.workflows.chat.stream(workflow_id="workflow", bot_id="bot") @@ -169,7 +170,7 @@ async def test_async_chat_stream_failed(self, respx_mock): assert events[0].chat.last_error.code == 5000 async def test_async_chat_stream_invalid_event(self, respx_mock): - coze = AsyncCoze(auth=TokenAuth(token="token")) + coze = AsyncCoze(auth=AsyncTokenAuth(token="token")) mock_workflows_chat_stream(respx_mock, read_file("testdata/chat_invalid_resp.txt")) diff --git a/tests/test_workspaces.py b/tests/test_workspaces.py index d0f25a9..57c78a5 100644 --- a/tests/test_workspaces.py +++ b/tests/test_workspaces.py @@ -1,7 +1,7 @@ import httpx import pytest -from cozepy import AsyncCoze, Coze, TokenAuth, Workspace, WorkspaceRoleType, WorkspaceType +from cozepy import AsyncCoze, AsyncTokenAuth, Coze, TokenAuth, Workspace, WorkspaceRoleType, WorkspaceType def mock_list_workspaces(respx_mock, total_count, page): @@ -70,7 +70,7 @@ def test_sync_workspaces_list(self, respx_mock): @pytest.mark.asyncio class TestAsyncWorkspaces: async def test_async_workspaces_list(self, respx_mock): - coze = AsyncCoze(auth=TokenAuth(token="token")) + coze = AsyncCoze(auth=AsyncTokenAuth(token="token")) total = 10 size = 1