From e251da0513afaa5a22cfbff04649f6fe3a3dcff9 Mon Sep 17 00:00:00 2001 From: Harry Le Date: Fri, 7 Mar 2025 13:23:46 +0700 Subject: [PATCH 1/5] test: check on ci --- .../assistants/test_api_create_assistant.py | 201 ++++++++++++++++++ .../runner/cortex-llamacpp-e2e-nightly.py | 2 + engine/e2e-test/runner/main.py | 2 + 3 files changed, 205 insertions(+) create mode 100644 engine/e2e-test/api/assistants/test_api_create_assistant.py diff --git a/engine/e2e-test/api/assistants/test_api_create_assistant.py b/engine/e2e-test/api/assistants/test_api_create_assistant.py new file mode 100644 index 000000000..5c042a9d6 --- /dev/null +++ b/engine/e2e-test/api/assistants/test_api_create_assistant.py @@ -0,0 +1,201 @@ +import pytest +import requests +from utils.test_runner import start_server, stop_server +import jsonschema +import time +from utils.logger import log_response +from utils.assertion import assert_equal + + +class TestApiCreateAssistant: + + @pytest.fixture(autouse=True) + def setup_and_teardown(self): + # Setup + success = start_server() + if not success: + raise Exception("Failed to start server") + + yield + + # Teardown + stop_server() + + def test_api_create_assistant_successfully(self): + headers = { + "Content-Type": "application/json", + "Authorization": "Bearer apikey1" + } + + data = { + "description": "", + "instructions": "", + "metadata": { + "ANY_ADDITIONAL_PROPERTY": "anything" + }, + "model": "tinyllama:1b", + "name": "test_assistant", + "response_format": "auto", + "temperature": 1, + "tool_resources": { + "code_interpreter": {}, + "file_search": {} + }, + "tools": [ + { + "type": "code_interpreter" + } + ], + "top_p": 1 + } + + post_assistant_url = "http://localhost:3928/v1/assistants" + res=requests.get(post_assistant_url) + log_response(res.text, "test_api_create_assistant_successfully") + + + response = requests.post( + post_assistant_url, headers=headers, json=data + ) + log_response(response.text, "test_api_create_assistant_successfully") + json_data = response.json() + assert_equal(response.status_code,200) + + schema = { + "properties": { + "created_at": { + "description": "Unix timestamp (in seconds) of when the assistant was created.", + "type": "integer" + }, + "description": { + "description": "The description of the assistant.", + "type": "string" + }, + "id": { + "description": "The unique identifier of the assistant.", + "type": "string" + }, + "instructions": { + "description": "Instructions for the assistant's behavior.", + "type": "string" + }, + "metadata": { + "additionalProperties": True, + "description": "Set of key-value pairs that can be attached to the assistant.", + "type": "object" + }, + "model": { + "description": "The model identifier used by the assistant.", + "type": "string" + }, + "name": { + "description": "The name of the assistant.", + "type": "string" + }, + "object": { + "description": "The object type, which is always 'assistant'.", + "enum": [ + "assistant" + ], + "type": "string" + }, + "response_format": { + "oneOf": [ + { + "enum": [ + "auto" + ], + "type": "string" + }, + { + "type": "object" + } + ] + }, + "temperature": { + "description": "Temperature parameter for response generation.", + "format": "float", + "type": "number" + }, + "tool_resources": { + "description": "Resources used by the assistant's tools.", + "properties": { + "code_interpreter": { + "type": "object" + }, + "file_search": { + "type": "object" + } + }, + "type": "object" + }, + "tools": { + "description": "A list of tools enabled on the assistant.", + "items": { + "properties": { + "type": { + "enum": [ + "code_interpreter", + "file_search", + "function" + ], + "type": "string" + } + }, + "type": "object" + }, + "type": "array" + }, + "top_p": { + "description": "Top p parameter for response generation.", + "format": "float", + "type": "number" + } + }, + "required": [ + "id", + "object", + "created_at", + "model", + "metadata" + ], + "type": "object" + } + + # Validate response schema + jsonschema.validate(instance=json_data, schema=schema) + + # def test_create_assistant(self): + # # time.sleep(30) + # url = "http://localhost:3928/v1/assistants" + # headers = { + # "OpenAI-Beta": "assistants=v1", + # "Content-Type": "application/json", + # "Authorization": "Bearer apikey1" + # } + # payload = { + # "description": "", + # "instructions": "", + # "metadata": { + # "ANY_ADDITIONAL_PROPERTY": "anything" + # }, + # "model": "tinyllama:1b", + # "name": "test_assistant", + # "response_format": "auto", + # "temperature": 1, + # "tool_resources": { + # "code_interpreter": {}, + # "file_search": {} + # }, + # "tools": [ + # {"type": "code_interpreter"} + # ], + # "top_p": 1 + # } + + # response = requests.post(url, headers=headers, json=payload) + + # print(f"Status Code: {response.status_code}") + # print(f"Response Body: {response.text}") + + # assert response.status_code == 200 \ No newline at end of file diff --git a/engine/e2e-test/runner/cortex-llamacpp-e2e-nightly.py b/engine/e2e-test/runner/cortex-llamacpp-e2e-nightly.py index e78baf951..be6c9c1af 100644 --- a/engine/e2e-test/runner/cortex-llamacpp-e2e-nightly.py +++ b/engine/e2e-test/runner/cortex-llamacpp-e2e-nightly.py @@ -36,6 +36,8 @@ from api.thread.test_api_delete_thread import TestApiDeleteThread from api.thread.test_api_get_thread import TestApiGetThread from api.thread.test_api_get_list_thread import TestApiGetListThread +from api.assistants.test_api_create_assistant import TestApiCreateAssistant + ### from cli.engines.test_cli_engine_get import TestCliEngineGet diff --git a/engine/e2e-test/runner/main.py b/engine/e2e-test/runner/main.py index 3327625d2..8b19ff5f0 100644 --- a/engine/e2e-test/runner/main.py +++ b/engine/e2e-test/runner/main.py @@ -36,6 +36,8 @@ from api.thread.test_api_delete_thread import TestApiDeleteThread from api.thread.test_api_get_thread import TestApiGetThread from api.thread.test_api_get_list_thread import TestApiGetListThread +from api.assistants.test_api_create_assistant import TestApiCreateAssistant + ### from cli.engines.test_cli_engine_get import TestCliEngineGet From fe9dab9b4a9f59193b5a06c696bcabb78f70a5c0 Mon Sep 17 00:00:00 2001 From: Harry Le Date: Fri, 7 Mar 2025 14:48:50 +0700 Subject: [PATCH 2/5] test: check all in ci --- .../assistants/test_api_create_assistant.py | 38 +----- .../assistants/test_api_delete_assistant.py | 105 +++++++++++++++ .../api/assistants/test_api_get_assistant.py | 109 +++++++++++++++ .../assistants/test_api_get_list_assistant.py | 124 ++++++++++++++++++ .../runner/cortex-llamacpp-e2e-nightly.py | 4 +- engine/e2e-test/runner/main.py | 3 + 6 files changed, 345 insertions(+), 38 deletions(-) create mode 100644 engine/e2e-test/api/assistants/test_api_delete_assistant.py create mode 100644 engine/e2e-test/api/assistants/test_api_get_assistant.py create mode 100644 engine/e2e-test/api/assistants/test_api_get_list_assistant.py diff --git a/engine/e2e-test/api/assistants/test_api_create_assistant.py b/engine/e2e-test/api/assistants/test_api_create_assistant.py index 5c042a9d6..5168eda04 100644 --- a/engine/e2e-test/api/assistants/test_api_create_assistant.py +++ b/engine/e2e-test/api/assistants/test_api_create_assistant.py @@ -2,7 +2,6 @@ import requests from utils.test_runner import start_server, stop_server import jsonschema -import time from utils.logger import log_response from utils.assertion import assert_equal @@ -24,7 +23,6 @@ def setup_and_teardown(self): def test_api_create_assistant_successfully(self): headers = { "Content-Type": "application/json", - "Authorization": "Bearer apikey1" } data = { @@ -164,38 +162,4 @@ def test_api_create_assistant_successfully(self): # Validate response schema jsonschema.validate(instance=json_data, schema=schema) - - # def test_create_assistant(self): - # # time.sleep(30) - # url = "http://localhost:3928/v1/assistants" - # headers = { - # "OpenAI-Beta": "assistants=v1", - # "Content-Type": "application/json", - # "Authorization": "Bearer apikey1" - # } - # payload = { - # "description": "", - # "instructions": "", - # "metadata": { - # "ANY_ADDITIONAL_PROPERTY": "anything" - # }, - # "model": "tinyllama:1b", - # "name": "test_assistant", - # "response_format": "auto", - # "temperature": 1, - # "tool_resources": { - # "code_interpreter": {}, - # "file_search": {} - # }, - # "tools": [ - # {"type": "code_interpreter"} - # ], - # "top_p": 1 - # } - - # response = requests.post(url, headers=headers, json=payload) - - # print(f"Status Code: {response.status_code}") - # print(f"Response Body: {response.text}") - - # assert response.status_code == 200 \ No newline at end of file + \ No newline at end of file diff --git a/engine/e2e-test/api/assistants/test_api_delete_assistant.py b/engine/e2e-test/api/assistants/test_api_delete_assistant.py new file mode 100644 index 000000000..905687f3c --- /dev/null +++ b/engine/e2e-test/api/assistants/test_api_delete_assistant.py @@ -0,0 +1,105 @@ +import pytest +import requests +from utils.test_runner import start_server, stop_server +import jsonschema +from utils.logger import log_response +from utils.assertion import assert_equal + + +class TestApiDeleteAssistant: + + @pytest.fixture(autouse=True) + def setup_and_teardown(self): + # Setup + success = start_server() + if not success: + raise Exception("Failed to start server") + + yield + + # Teardown + stop_server() + + def test_api_delete_assistant_successfully(self): + headers = { + "Content-Type": "application/json", + } + + data = { + "description": "", + "instructions": "", + "metadata": { + "ANY_ADDITIONAL_PROPERTY": "anything" + }, + "model": "tinyllama:1b", + "name": "test_assistant", + "response_format": "auto", + "temperature": 1, + "tool_resources": { + "code_interpreter": {}, + "file_search": {} + }, + "tools": [ + { + "type": "code_interpreter" + } + ], + "top_p": 1 + } + + assistant_url = "http://localhost:3928/v1/assistants" + response = requests.post( + assistant_url, headers=headers, json=data + ) + json_data = response.json() + log_response(json_data, "test_api_delete_assistant_successfully") + assert_equal(response.status_code,200) + + assistant_id=response["id"] + + # Get list assistant + assistantid_url=f"http://localhost:3928/v1/assistants/{assistant_id}" + response_del_assistant = requests.delete( + assistantid_url + ) + json_data_del_assistant = response_del_assistant.json() + log_response(json_data_del_assistant, "test_api_delete_assistant_successfully") + assert_equal(response_del_assistant.status_code,200) + + schema = { + "properties": { + "deleted": { + "description": "Indicates the assistant was successfully deleted.", + "enum": [ + True + ], + "type": "boolean" + }, + "id": { + "description": "The unique identifier of the deleted assistant.", + "type": "string" + }, + "object": { + "description": "The object type for a deleted assistant.", + "enum": [ + "assistant.deleted" + ], + "type": "string" + } + }, + "required": [ + "id", + "object", + "deleted" + ], + "type": "object" + } + + # Validate response schema + jsonschema.validate(instance=response_del_assistant, schema=schema) + + # Assert content + assert_equal(response_del_assistant["deleted"], True) + assert_equal(response_del_assistant["id"], assistant_id) + assert_equal(response_del_assistant["object"], "assistant.deleted") + \ No newline at end of file diff --git a/engine/e2e-test/api/assistants/test_api_get_assistant.py b/engine/e2e-test/api/assistants/test_api_get_assistant.py new file mode 100644 index 000000000..d1be6bbc2 --- /dev/null +++ b/engine/e2e-test/api/assistants/test_api_get_assistant.py @@ -0,0 +1,109 @@ +import pytest +import requests +from utils.test_runner import start_server, stop_server +import jsonschema +from utils.logger import log_response +from utils.assertion import assert_equal + + +class TestApiGetAssistant: + + @pytest.fixture(autouse=True) + def setup_and_teardown(self): + # Setup + success = start_server() + if not success: + raise Exception("Failed to start server") + + yield + + # Teardown + stop_server() + + def test_api_get_assistant_successfully(self): + headers = { + "Content-Type": "application/json", + } + + data = { + "description": "", + "instructions": "", + "metadata": { + "ANY_ADDITIONAL_PROPERTY": "anything" + }, + "model": "tinyllama:1b", + "name": "test_assistant", + "response_format": "auto", + "temperature": 1, + "tool_resources": { + "code_interpreter": {}, + "file_search": {} + }, + "tools": [ + { + "type": "code_interpreter" + } + ], + "top_p": 1 + } + + assistant_url = "http://localhost:3928/v1/assistants" + response = requests.post( + assistant_url, headers=headers, json=data + ) + json_data = response.json() + log_response(json_data, "test_api_get_assistant_successfully") + assert_equal(response.status_code,200) + + assistant_id=response["id"] + + # Get list assistant + assistantid_url=f"http://localhost:3928/v1/assistants/{assistant_id}" + response_assistant = requests.get( + assistantid_url + ) + json_data_assistant = response_assistant.json() + log_response(json_data_assistant, "test_api_get_assistant_successfully") + assert_equal(response_assistant.status_code,200) + + schema = { + "properties": { + "created_at": { + "description": "Unix timestamp (in seconds) of when the assistant was created.", + "type": "integer" + }, + "id": { + "description": "The unique identifier of the assistant.", + "type": "string" + }, + "metadata": { + "additionalProperties": True, + "description": "Set of key-value pairs attached to the assistant.", + "type": "object" + }, + "model": { + "description": "The model identifier used by the assistant.", + "type": "string" + }, + "object": { + "description": "The object type, which is always 'assistant'.", + "enum": [ + "assistant" + ], + "type": "string" + } + }, + "required": [ + "id", + "object", + "created_at", + "model", + "metadata" + ], + "type": "object" + } + + # Validate response schema + jsonschema.validate(instance=response_assistant, schema=schema) + assert_equal(json_data_assistant["id"], assistant_id) + \ No newline at end of file diff --git a/engine/e2e-test/api/assistants/test_api_get_list_assistant.py b/engine/e2e-test/api/assistants/test_api_get_list_assistant.py new file mode 100644 index 000000000..2e884f392 --- /dev/null +++ b/engine/e2e-test/api/assistants/test_api_get_list_assistant.py @@ -0,0 +1,124 @@ +import pytest +import requests +from utils.test_runner import start_server, stop_server +import jsonschema +from utils.logger import log_response +from utils.assertion import assert_equal + + +class TestApiGetListAssistant: + + @pytest.fixture(autouse=True) + def setup_and_teardown(self): + # Setup + success = start_server() + if not success: + raise Exception("Failed to start server") + + yield + + # Teardown + stop_server() + + def test_api_get_list_assistant_successfully(self): + headers = { + "Content-Type": "application/json", + } + + data = { + "description": "", + "instructions": "", + "metadata": { + "ANY_ADDITIONAL_PROPERTY": "anything" + }, + "model": "tinyllama:1b", + "name": "test_assistant", + "response_format": "auto", + "temperature": 1, + "tool_resources": { + "code_interpreter": {}, + "file_search": {} + }, + "tools": [ + { + "type": "code_interpreter" + } + ], + "top_p": 1 + } + + assistant_url = "http://localhost:3928/v1/assistants" + response = requests.post( + assistant_url, headers=headers, json=data + ) + json_data = response.json() + log_response(json_data, "test_api_get_list_assistant_successfully") + assert_equal(response.status_code,200) + + # Get list assistant + response_list_assistant = requests.get( + assistant_url + ) + json_data_list_assistant = response_list_assistant.json() + log_response(json_data_list_assistant, "test_api_get_list_assistant_successfully") + assert_equal(response_list_assistant.status_code,200) + + schema = { + "properties": { + "data": { + "items": { + "properties": { + "created_at": { + "description": "Unix timestamp (in seconds) of when the assistant was created.", + "type": "integer" + }, + "id": { + "description": "The unique identifier of the assistant.", + "type": "string" + }, + "metadata": { + "additionalProperties": True, + "description": "Set of key-value pairs that can be attached to the assistant.", + "type": "object" + }, + "model": { + "description": "The model identifier used by the assistant.", + "type": "string" + }, + "object": { + "description": "The object type, which is always 'assistant'.", + "enum": [ + "assistant" + ], + "type": "string" + } + }, + "required": [ + "id", + "object", + "created_at", + "model", + "metadata" + ], + "type": "object" + }, + "type": "array" + }, + "object": { + "description": "The object type, which is always 'list' for a list response.", + "enum": [ + "list" + ], + "type": "string" + } + }, + "required": [ + "object", + "data" + ], + "type": "object" + } + + # Validate response schema + jsonschema.validate(instance=response_list_assistant, schema=schema) + \ No newline at end of file diff --git a/engine/e2e-test/runner/cortex-llamacpp-e2e-nightly.py b/engine/e2e-test/runner/cortex-llamacpp-e2e-nightly.py index be6c9c1af..dcd3bccc9 100644 --- a/engine/e2e-test/runner/cortex-llamacpp-e2e-nightly.py +++ b/engine/e2e-test/runner/cortex-llamacpp-e2e-nightly.py @@ -37,7 +37,9 @@ from api.thread.test_api_get_thread import TestApiGetThread from api.thread.test_api_get_list_thread import TestApiGetListThread from api.assistants.test_api_create_assistant import TestApiCreateAssistant - +from api.assistants.test_api_get_list_assistant import TestApiGetListAssistant +from api.assistants.test_api_get_assistant import TestApiGetAssistant +from api.assistants.test_api_delete_assistant import TestApiDeleteAssistant ### from cli.engines.test_cli_engine_get import TestCliEngineGet diff --git a/engine/e2e-test/runner/main.py b/engine/e2e-test/runner/main.py index 8b19ff5f0..fa8c97632 100644 --- a/engine/e2e-test/runner/main.py +++ b/engine/e2e-test/runner/main.py @@ -37,6 +37,9 @@ from api.thread.test_api_get_thread import TestApiGetThread from api.thread.test_api_get_list_thread import TestApiGetListThread from api.assistants.test_api_create_assistant import TestApiCreateAssistant +from api.assistants.test_api_get_list_assistant import TestApiGetListAssistant +from api.assistants.test_api_get_assistant import TestApiGetAssistant +from api.assistants.test_api_delete_assistant import TestApiDeleteAssistant ### From b4778635caa4e5061ac2ee0c877129c06d7cc4b1 Mon Sep 17 00:00:00 2001 From: Harry Le Date: Fri, 7 Mar 2025 15:45:37 +0700 Subject: [PATCH 3/5] test: fix --- .../assistants/test_api_delete_assistant.py | 2 +- .../api/assistants/test_api_get_assistant.py | 2 +- .../assistants/test_api_get_list_assistant.py | 143 ++++++++++++------ 3 files changed, 95 insertions(+), 52 deletions(-) diff --git a/engine/e2e-test/api/assistants/test_api_delete_assistant.py b/engine/e2e-test/api/assistants/test_api_delete_assistant.py index 905687f3c..dad469f22 100644 --- a/engine/e2e-test/api/assistants/test_api_delete_assistant.py +++ b/engine/e2e-test/api/assistants/test_api_delete_assistant.py @@ -55,7 +55,7 @@ def test_api_delete_assistant_successfully(self): log_response(json_data, "test_api_delete_assistant_successfully") assert_equal(response.status_code,200) - assistant_id=response["id"] + assistant_id=json_data["id"] # Get list assistant assistantid_url=f"http://localhost:3928/v1/assistants/{assistant_id}" diff --git a/engine/e2e-test/api/assistants/test_api_get_assistant.py b/engine/e2e-test/api/assistants/test_api_get_assistant.py index d1be6bbc2..a336c4a48 100644 --- a/engine/e2e-test/api/assistants/test_api_get_assistant.py +++ b/engine/e2e-test/api/assistants/test_api_get_assistant.py @@ -55,7 +55,7 @@ def test_api_get_assistant_successfully(self): log_response(json_data, "test_api_get_assistant_successfully") assert_equal(response.status_code,200) - assistant_id=response["id"] + assistant_id=json_data["id"] # Get list assistant assistantid_url=f"http://localhost:3928/v1/assistants/{assistant_id}" diff --git a/engine/e2e-test/api/assistants/test_api_get_list_assistant.py b/engine/e2e-test/api/assistants/test_api_get_list_assistant.py index 2e884f392..0db37473a 100644 --- a/engine/e2e-test/api/assistants/test_api_get_list_assistant.py +++ b/engine/e2e-test/api/assistants/test_api_get_list_assistant.py @@ -64,59 +64,102 @@ def test_api_get_list_assistant_successfully(self): assert_equal(response_list_assistant.status_code,200) schema = { + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", "properties": { - "data": { - "items": { - "properties": { - "created_at": { - "description": "Unix timestamp (in seconds) of when the assistant was created.", - "type": "integer" - }, - "id": { - "description": "The unique identifier of the assistant.", - "type": "string" - }, - "metadata": { - "additionalProperties": True, - "description": "Set of key-value pairs that can be attached to the assistant.", - "type": "object" - }, - "model": { - "description": "The model identifier used by the assistant.", - "type": "string" - }, - "object": { - "description": "The object type, which is always 'assistant'.", - "enum": [ - "assistant" - ], - "type": "string" - } - }, - "required": [ - "id", - "object", - "created_at", - "model", - "metadata" - ], - "type": "object" + "object": { + "type": "string", + "enum": ["list"] }, - "type": "array" - }, - "object": { - "description": "The object type, which is always 'list' for a list response.", - "enum": [ - "list" - ], - "type": "string" - } + "data": { + "type": "array", + "items": { + "type": "object", + "properties": { + "created_at": { + "type": "integer" + }, + "description": { + "type": "string" + }, + "id": { + "type": "string" + }, + "instructions": { + "type": "string" + }, + "metadata": { + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "model": { + "type": "string" + }, + "name": { + "type": "string" + }, + "object": { + "type": "string", + "enum": ["assistant"] + }, + "temperature": { + "type": "number" + }, + "tool_resources": { + "type": "object", + "properties": { + "file_search": { + "type": "object", + "properties": { + "vector_store_ids": { + "type": "array", + "items": { + "type": "string" + } + } + }, + "required": ["vector_store_ids"] + } + }, + "required": ["file_search"] + }, + "tools": { + "type": "array", + "items": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": ["code_interpreter"] + } + }, + "required": ["type"] + } + }, + "top_p": { + "type": "number" + } + }, + "required": [ + "created_at", + "description", + "id", + "instructions", + "metadata", + "model", + "name", + "object", + "temperature", + "tool_resources", + "tools", + "top_p" + ] + } + } }, - "required": [ - "object", - "data" - ], - "type": "object" + "required": ["object", "data"] } # Validate response schema From e1b6d816faca9cabc94ce7c48c223651152eddf3 Mon Sep 17 00:00:00 2001 From: Harry Le Date: Fri, 7 Mar 2025 16:09:15 +0700 Subject: [PATCH 4/5] test: fix 2 --- .../assistants/test_api_delete_assistant.py | 40 +++++++------------ .../api/assistants/test_api_get_assistant.py | 5 ++- .../assistants/test_api_get_list_assistant.py | 2 +- 3 files changed, 20 insertions(+), 27 deletions(-) diff --git a/engine/e2e-test/api/assistants/test_api_delete_assistant.py b/engine/e2e-test/api/assistants/test_api_delete_assistant.py index dad469f22..e955e4eb4 100644 --- a/engine/e2e-test/api/assistants/test_api_delete_assistant.py +++ b/engine/e2e-test/api/assistants/test_api_delete_assistant.py @@ -67,36 +67,26 @@ def test_api_delete_assistant_successfully(self): assert_equal(response_del_assistant.status_code,200) schema = { + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", "properties": { - "deleted": { - "description": "Indicates the assistant was successfully deleted.", - "enum": [ - True - ], - "type": "boolean" - }, - "id": { - "description": "The unique identifier of the deleted assistant.", - "type": "string" - }, - "object": { - "description": "The object type for a deleted assistant.", - "enum": [ - "assistant.deleted" - ], - "type": "string" - } + "deleted": { + "type": "boolean" + }, + "id": { + "type": "string" + }, + "object": { + "type": "string", + "enum": ["assistant.deleted"] + } }, - "required": [ - "id", - "object", - "deleted" - ], - "type": "object" + "required": ["deleted", "id", "object"] } + # Validate response schema - jsonschema.validate(instance=response_del_assistant, schema=schema) + jsonschema.validate(instance=json_data_del_assistant, schema=schema) # Assert content assert_equal(response_del_assistant["deleted"], True) diff --git a/engine/e2e-test/api/assistants/test_api_get_assistant.py b/engine/e2e-test/api/assistants/test_api_get_assistant.py index a336c4a48..99f4b1278 100644 --- a/engine/e2e-test/api/assistants/test_api_get_assistant.py +++ b/engine/e2e-test/api/assistants/test_api_get_assistant.py @@ -58,6 +58,9 @@ def test_api_get_assistant_successfully(self): assistant_id=json_data["id"] # Get list assistant + headers = { + "OpenAI-Beta": "assistants=v2" + } assistantid_url=f"http://localhost:3928/v1/assistants/{assistant_id}" response_assistant = requests.get( assistantid_url @@ -104,6 +107,6 @@ def test_api_get_assistant_successfully(self): } # Validate response schema - jsonschema.validate(instance=response_assistant, schema=schema) + jsonschema.validate(instance=json_data_assistant, schema=schema) assert_equal(json_data_assistant["id"], assistant_id) \ No newline at end of file diff --git a/engine/e2e-test/api/assistants/test_api_get_list_assistant.py b/engine/e2e-test/api/assistants/test_api_get_list_assistant.py index 0db37473a..4115bbe8c 100644 --- a/engine/e2e-test/api/assistants/test_api_get_list_assistant.py +++ b/engine/e2e-test/api/assistants/test_api_get_list_assistant.py @@ -163,5 +163,5 @@ def test_api_get_list_assistant_successfully(self): } # Validate response schema - jsonschema.validate(instance=response_list_assistant, schema=schema) + jsonschema.validate(instance=json_data_list_assistant, schema=schema) \ No newline at end of file From 416b3d3805e11374e3da90226723da2bd9fdb38f Mon Sep 17 00:00:00 2001 From: Harry Le Date: Fri, 7 Mar 2025 16:19:33 +0700 Subject: [PATCH 5/5] test: fix 3 --- engine/e2e-test/api/assistants/test_api_delete_assistant.py | 6 +++--- engine/e2e-test/api/assistants/test_api_get_assistant.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/engine/e2e-test/api/assistants/test_api_delete_assistant.py b/engine/e2e-test/api/assistants/test_api_delete_assistant.py index e955e4eb4..e45529a4d 100644 --- a/engine/e2e-test/api/assistants/test_api_delete_assistant.py +++ b/engine/e2e-test/api/assistants/test_api_delete_assistant.py @@ -89,7 +89,7 @@ def test_api_delete_assistant_successfully(self): jsonschema.validate(instance=json_data_del_assistant, schema=schema) # Assert content - assert_equal(response_del_assistant["deleted"], True) - assert_equal(response_del_assistant["id"], assistant_id) - assert_equal(response_del_assistant["object"], "assistant.deleted") + assert_equal(json_data_del_assistant["deleted"], True) + assert_equal(json_data_del_assistant["id"], assistant_id) + assert_equal(json_data_del_assistant["object"], "assistant.deleted") \ No newline at end of file diff --git a/engine/e2e-test/api/assistants/test_api_get_assistant.py b/engine/e2e-test/api/assistants/test_api_get_assistant.py index 99f4b1278..d90d77a58 100644 --- a/engine/e2e-test/api/assistants/test_api_get_assistant.py +++ b/engine/e2e-test/api/assistants/test_api_get_assistant.py @@ -63,7 +63,7 @@ def test_api_get_assistant_successfully(self): } assistantid_url=f"http://localhost:3928/v1/assistants/{assistant_id}" response_assistant = requests.get( - assistantid_url + assistantid_url, headers= headers ) json_data_assistant = response_assistant.json() log_response(json_data_assistant, "test_api_get_assistant_successfully")