diff --git a/src/norbix_python/client.py b/src/norbix_python/client.py index 2e2fdf2..13beb6d 100644 --- a/src/norbix_python/client.py +++ b/src/norbix_python/client.py @@ -12,7 +12,7 @@ DEFAULT_BASE_URL_API = "https://api.norbix.ai" DEFAULT_BASE_URL_HUB = "https://hub.norbix.ai" -DEFAULT_VERSION = "v2" +DEFAULT_VERSION = "v3" DEFAULT_TIMEOUT = 30.0 diff --git a/tests/api/test_ai.py b/tests/api/test_ai.py index 2d9c1dc..4f03c27 100644 --- a/tests/api/test_ai.py +++ b/tests/api/test_ai.py @@ -27,7 +27,7 @@ def test_api_ai_get_end_user_chat_availability_request_shape() -> None: client.api.ai.get_end_user_chat_availability() assert transport.last_request is not None assert transport.last_request['method'] == 'GET' - assert transport.last_request['url'].endswith('/v2/ai/chat/availability') + assert transport.last_request['url'].endswith('/v3/ai/chat/availability') assert transport.last_request['headers']['authorization'] == 'Bearer test-token' assert transport.last_request['headers']['x-cm-projectid'] == 'test-project' @@ -37,7 +37,7 @@ def test_api_ai_list_end_user_chat_sessions_request_shape() -> None: client.api.ai.list_end_user_chat_sessions() assert transport.last_request is not None assert transport.last_request['method'] == 'GET' - assert transport.last_request['url'].endswith('/v2/ai/chat/sessions') + assert transport.last_request['url'].endswith('/v3/ai/chat/sessions') assert transport.last_request['headers']['authorization'] == 'Bearer test-token' assert transport.last_request['headers']['x-cm-projectid'] == 'test-project' @@ -47,7 +47,7 @@ def test_api_ai_create_end_user_chat_session_request_shape() -> None: client.api.ai.create_end_user_chat_session() assert transport.last_request is not None assert transport.last_request['method'] == 'POST' - assert transport.last_request['url'].endswith('/v2/ai/chat/sessions') + assert transport.last_request['url'].endswith('/v3/ai/chat/sessions') assert transport.last_request['headers']['authorization'] == 'Bearer test-token' assert transport.last_request['headers']['x-cm-projectid'] == 'test-project' @@ -57,7 +57,7 @@ def test_api_ai_get_end_user_chat_session_request_shape() -> None: client.api.ai.get_end_user_chat_session(session_id="stub-SessionId") assert transport.last_request is not None assert transport.last_request['method'] == 'GET' - assert transport.last_request['url'].endswith('/v2/ai/chat/sessions/stub-SessionId') + assert transport.last_request['url'].endswith('/v3/ai/chat/sessions/stub-SessionId') assert transport.last_request['headers']['authorization'] == 'Bearer test-token' assert transport.last_request['headers']['x-cm-projectid'] == 'test-project' @@ -67,7 +67,7 @@ def test_api_ai_rename_end_user_chat_session_request_shape() -> None: client.api.ai.rename_end_user_chat_session(session_id="stub-SessionId") assert transport.last_request is not None assert transport.last_request['method'] == 'PATCH' - assert transport.last_request['url'].endswith('/v2/ai/chat/sessions/stub-SessionId') + assert transport.last_request['url'].endswith('/v3/ai/chat/sessions/stub-SessionId') assert transport.last_request['headers']['authorization'] == 'Bearer test-token' assert transport.last_request['headers']['x-cm-projectid'] == 'test-project' @@ -77,7 +77,7 @@ def test_api_ai_delete_end_user_chat_session_request_shape() -> None: client.api.ai.delete_end_user_chat_session(session_id="stub-SessionId") assert transport.last_request is not None assert transport.last_request['method'] == 'DELETE' - assert transport.last_request['url'].endswith('/v2/ai/chat/sessions/stub-SessionId') + assert transport.last_request['url'].endswith('/v3/ai/chat/sessions/stub-SessionId') assert transport.last_request['headers']['authorization'] == 'Bearer test-token' assert transport.last_request['headers']['x-cm-projectid'] == 'test-project' @@ -87,7 +87,7 @@ def test_api_ai_pin_end_user_chat_session_request_shape() -> None: client.api.ai.pin_end_user_chat_session(session_id="stub-SessionId") assert transport.last_request is not None assert transport.last_request['method'] == 'PUT' - assert transport.last_request['url'].endswith('/v2/ai/chat/sessions/stub-SessionId/pin') + assert transport.last_request['url'].endswith('/v3/ai/chat/sessions/stub-SessionId/pin') assert transport.last_request['headers']['authorization'] == 'Bearer test-token' assert transport.last_request['headers']['x-cm-projectid'] == 'test-project' @@ -97,7 +97,7 @@ def test_api_ai_archive_end_user_chat_session_request_shape() -> None: client.api.ai.archive_end_user_chat_session(session_id="stub-SessionId") assert transport.last_request is not None assert transport.last_request['method'] == 'PUT' - assert transport.last_request['url'].endswith('/v2/ai/chat/sessions/stub-SessionId/archive') + assert transport.last_request['url'].endswith('/v3/ai/chat/sessions/stub-SessionId/archive') assert transport.last_request['headers']['authorization'] == 'Bearer test-token' assert transport.last_request['headers']['x-cm-projectid'] == 'test-project' @@ -107,7 +107,7 @@ def test_api_ai_get_end_user_chat_entries_request_shape() -> None: client.api.ai.get_end_user_chat_entries(session_id="stub-SessionId") assert transport.last_request is not None assert transport.last_request['method'] == 'GET' - assert transport.last_request['url'].endswith('/v2/ai/chat/sessions/stub-SessionId/entries') + assert transport.last_request['url'].endswith('/v3/ai/chat/sessions/stub-SessionId/entries') assert transport.last_request['headers']['authorization'] == 'Bearer test-token' assert transport.last_request['headers']['x-cm-projectid'] == 'test-project' @@ -117,7 +117,7 @@ def test_api_ai_set_end_user_chat_entry_feedback_request_shape() -> None: client.api.ai.set_end_user_chat_entry_feedback(session_id="stub-SessionId", entry_id="stub-EntryId") assert transport.last_request is not None assert transport.last_request['method'] == 'PUT' - assert transport.last_request['url'].endswith('/v2/ai/chat/sessions/stub-SessionId/entries/stub-EntryId/feedback') + assert transport.last_request['url'].endswith('/v3/ai/chat/sessions/stub-SessionId/entries/stub-EntryId/feedback') assert transport.last_request['headers']['authorization'] == 'Bearer test-token' assert transport.last_request['headers']['x-cm-projectid'] == 'test-project' @@ -127,7 +127,7 @@ def test_api_ai_list_end_user_chat_attachments_request_shape() -> None: client.api.ai.list_end_user_chat_attachments(session_id="stub-SessionId") assert transport.last_request is not None assert transport.last_request['method'] == 'GET' - assert transport.last_request['url'].endswith('/v2/ai/chat/sessions/stub-SessionId/attachments') + assert transport.last_request['url'].endswith('/v3/ai/chat/sessions/stub-SessionId/attachments') assert transport.last_request['headers']['authorization'] == 'Bearer test-token' assert transport.last_request['headers']['x-cm-projectid'] == 'test-project' @@ -137,7 +137,7 @@ def test_api_ai_upload_end_user_chat_attachment_request_shape() -> None: client.api.ai.upload_end_user_chat_attachment(session_id="stub-SessionId") assert transport.last_request is not None assert transport.last_request['method'] == 'POST' - assert transport.last_request['url'].endswith('/v2/ai/chat/sessions/stub-SessionId/attachments') + assert transport.last_request['url'].endswith('/v3/ai/chat/sessions/stub-SessionId/attachments') assert transport.last_request['headers']['authorization'] == 'Bearer test-token' assert transport.last_request['headers']['x-cm-projectid'] == 'test-project' @@ -147,7 +147,7 @@ def test_api_ai_delete_end_user_chat_attachment_request_shape() -> None: client.api.ai.delete_end_user_chat_attachment(attachment_id="stub-AttachmentId") assert transport.last_request is not None assert transport.last_request['method'] == 'DELETE' - assert transport.last_request['url'].endswith('/v2/ai/chat/attachments/stub-AttachmentId') + assert transport.last_request['url'].endswith('/v3/ai/chat/attachments/stub-AttachmentId') assert transport.last_request['headers']['authorization'] == 'Bearer test-token' assert transport.last_request['headers']['x-cm-projectid'] == 'test-project' @@ -157,7 +157,7 @@ def test_api_ai_list_end_user_chat_memory_request_shape() -> None: client.api.ai.list_end_user_chat_memory() assert transport.last_request is not None assert transport.last_request['method'] == 'GET' - assert transport.last_request['url'].endswith('/v2/ai/chat/memory') + assert transport.last_request['url'].endswith('/v3/ai/chat/memory') assert transport.last_request['headers']['authorization'] == 'Bearer test-token' assert transport.last_request['headers']['x-cm-projectid'] == 'test-project' @@ -167,7 +167,7 @@ def test_api_ai_forget_end_user_chat_memory_request_shape() -> None: client.api.ai.forget_end_user_chat_memory(note_id="stub-NoteId") assert transport.last_request is not None assert transport.last_request['method'] == 'DELETE' - assert transport.last_request['url'].endswith('/v2/ai/chat/memory/stub-NoteId') + assert transport.last_request['url'].endswith('/v3/ai/chat/memory/stub-NoteId') assert transport.last_request['headers']['authorization'] == 'Bearer test-token' assert transport.last_request['headers']['x-cm-projectid'] == 'test-project' @@ -177,7 +177,7 @@ def test_api_ai_start_end_user_chat_turn_request_shape() -> None: client.api.ai.start_end_user_chat_turn() assert transport.last_request is not None assert transport.last_request['method'] == 'POST' - assert transport.last_request['url'].endswith('/v2/ai/chat/turn') + assert transport.last_request['url'].endswith('/v3/ai/chat/turn') assert transport.last_request['headers']['authorization'] == 'Bearer test-token' assert transport.last_request['headers']['x-cm-projectid'] == 'test-project' diff --git a/tests/api/test_database.py b/tests/api/test_database.py index 76654de..0ebd5e2 100644 --- a/tests/api/test_database.py +++ b/tests/api/test_database.py @@ -170,7 +170,7 @@ def test_api_database_find_own_hits_the_own_route_with_query_values() -> None: assert transport.last_request["method"] == "GET" url = urlparse(transport.last_request["url"]) assert url.netloc == "api.norbix.ai" - assert url.path == "/v2/database/collections/products/own" + assert url.path == "/v3/database/collections/products/own" assert parse_qs(url.query) == {"pageSize": ["10"]} @@ -182,7 +182,7 @@ def test_api_database_find_merged_term_tree_hits_the_merged_tree_route() -> None assert transport.last_request["method"] == "GET" url = urlparse(transport.last_request["url"]) assert url.netloc == "api.norbix.ai" - assert url.path == "/v2/database/taxonomies/services/merged-tree" + assert url.path == "/v3/database/taxonomies/services/merged-tree" def test_api_database_audit_methods_exist_on_the_async_module() -> None: @@ -207,6 +207,6 @@ async def run() -> None: asyncio.run(run()) assert [(r.method, urlparse(str(r.url)).path) for r in seen] == [ - ("GET", "/v2/database/collections/products/own"), - ("GET", "/v2/database/taxonomies/services/merged-tree"), + ("GET", "/v3/database/collections/products/own"), + ("GET", "/v3/database/taxonomies/services/merged-tree"), ] diff --git a/tests/api/test_database_last_wave.py b/tests/api/test_database_last_wave.py index 02e52d6..1fb1881 100644 --- a/tests/api/test_database_last_wave.py +++ b/tests/api/test_database_last_wave.py @@ -113,7 +113,7 @@ def test_every_api_database_method_sends_its_documented_verb_and_path() -> None: assert transport.last_request is not None assert transport.last_request["method"] == verb, name sent = urlparse(transport.last_request["url"]).path - pattern = "^" + _TOKEN.sub("[^/]+", path.replace("{version}", "v2")) + "$" + pattern = "^" + _TOKEN.sub("[^/]+", path.replace("{version}", "v3")) + "$" assert re.match(pattern, sent), (name, sent) @@ -128,7 +128,7 @@ def test_update_many_sends_all_records_in_the_body() -> None: client.api.database.update_many("products", filter="{}", update='{"seen": true}', allRecords=True) assert transport.last_request is not None assert transport.last_request["method"] == "PUT" - assert urlparse(transport.last_request["url"]).path == "/v2/database/collections/products/many" + assert urlparse(transport.last_request["url"]).path == "/v3/database/collections/products/many" assert json.loads(transport.last_request["body"]) == { "filter": "{}", "update": '{"seen": true}', diff --git a/tests/api/test_database_schema_content.py b/tests/api/test_database_schema_content.py index 2d95ec3..9fc7ad2 100644 --- a/tests/api/test_database_schema_content.py +++ b/tests/api/test_database_schema_content.py @@ -94,7 +94,7 @@ def test_find_sends_expand_references_in_the_query() -> None: client, transport = _client() client.api.database.find("articles", expand_references=True, pageSize=10) assert transport.last_request is not None - assert urlparse(transport.last_request["url"]).path == "/v2/database/collections/articles" + assert urlparse(transport.last_request["url"]).path == "/v3/database/collections/articles" assert _query(transport) == {"expandReferences": ["true"], "pageSize": ["10"]} @@ -102,7 +102,7 @@ def test_find_one_sends_expand_references_in_the_query() -> None: client, transport = _client() client.api.database.find_one("articles", "rec_1", expand_references=True) assert transport.last_request is not None - assert urlparse(transport.last_request["url"]).path == "/v2/database/collections/articles/rec_1" + assert urlparse(transport.last_request["url"]).path == "/v3/database/collections/articles/rec_1" assert _query(transport) == {"expandReferences": ["true"]} @@ -110,7 +110,7 @@ def test_find_own_sends_expand_references_in_the_query() -> None: client, transport = _client() client.api.database.find_own("articles", expand_references=True) assert transport.last_request is not None - assert urlparse(transport.last_request["url"]).path == "/v2/database/collections/articles/own" + assert urlparse(transport.last_request["url"]).path == "/v3/database/collections/articles/own" assert _query(transport) == {"expandReferences": ["true"]} @@ -204,7 +204,7 @@ def test_update_one_sends_array_filters_string_as_given() -> None: ) assert transport.last_request is not None assert transport.last_request["method"] == "PUT" - assert urlparse(transport.last_request["url"]).path == "/v2/database/collections/orders/rec_1" + assert urlparse(transport.last_request["url"]).path == "/v3/database/collections/orders/rec_1" assert _body(transport) == { "update": '{"lines.$[line].qty": 3, "meta.words": 130}', "arrayFilters": '[{"line.sku": "A-1"}]', @@ -232,7 +232,7 @@ def test_update_many_sends_array_filters_in_the_body() -> None: array_filters="[]", ) assert transport.last_request is not None - assert urlparse(transport.last_request["url"]).path == "/v2/database/collections/orders/many" + assert urlparse(transport.last_request["url"]).path == "/v3/database/collections/orders/many" assert _body(transport) == {"filter": '{"status": "open"}', "update": '{"lines.$[].qty": 1}', "arrayFilters": "[]"} diff --git a/tests/api/test_public.py b/tests/api/test_public.py index d2ebf27..44d3025 100644 --- a/tests/api/test_public.py +++ b/tests/api/test_public.py @@ -41,7 +41,7 @@ def test_public_project_config_goes_to_the_api_host_without_auth(bearer_token: s assert result == {"displayName": "Shop"} assert seen[0].method == "GET" assert seen[0].url.host == "api.norbix.ai" - assert seen[0].url.path == "/v2/public/projects/pr_1/config" + assert seen[0].url.path == "/v3/public/projects/pr_1/config" assert "authorization" not in seen[0].headers @@ -57,7 +57,7 @@ def test_public_project_legal_puts_project_and_kind_in_the_path() -> None: assert result == LEGAL assert seen[0].method == "GET" - assert seen[0].url.path == "/v2/public/projects/pr_1/legal/terms" + assert seen[0].url.path == "/v3/public/projects/pr_1/legal/terms" assert "authorization" not in seen[0].headers assert client.Public is client.public @@ -80,7 +80,7 @@ async def run() -> None: asyncio.run(run()) assert [r.url.path for r in seen] == [ - "/v2/public/projects/pr_1/config", - "/v2/public/projects/pr_1/legal/privacy", + "/v3/public/projects/pr_1/config", + "/v3/public/projects/pr_1/legal/privacy", ] assert all("authorization" not in r.headers for r in seen) diff --git a/tests/hub/test_account.py b/tests/hub/test_account.py index 525104c..a35adc7 100644 --- a/tests/hub/test_account.py +++ b/tests/hub/test_account.py @@ -325,7 +325,7 @@ def test_hub_account_get_project_ai_settings_request_shape() -> None: client.hub.account.get_project_ai_settings(project_id="stub-projectId") assert transport.last_request is not None assert transport.last_request['method'] == 'GET' - assert transport.last_request['url'].endswith('/v2/account/projects/stub-projectId/ai/settings') + assert transport.last_request['url'].endswith('/v3/account/projects/stub-projectId/ai/settings') assert transport.last_request['headers']['authorization'] == 'Bearer test-token' assert transport.last_request['headers']['x-cm-projectid'] == 'test-project' @@ -335,7 +335,7 @@ def test_hub_account_update_project_ai_settings_request_shape() -> None: client.hub.account.update_project_ai_settings(project_id="stub-projectId") assert transport.last_request is not None assert transport.last_request['method'] == 'PUT' - assert transport.last_request['url'].endswith('/v2/account/projects/stub-projectId/ai/settings') + assert transport.last_request['url'].endswith('/v3/account/projects/stub-projectId/ai/settings') assert transport.last_request['headers']['authorization'] == 'Bearer test-token' assert transport.last_request['headers']['x-cm-projectid'] == 'test-project' @@ -345,7 +345,7 @@ def test_hub_account_create_project_ai_assistant_request_shape() -> None: client.hub.account.create_project_ai_assistant(project_id="stub-projectId") assert transport.last_request is not None assert transport.last_request['method'] == 'POST' - assert transport.last_request['url'].endswith('/v2/account/projects/stub-projectId/ai/assistants') + assert transport.last_request['url'].endswith('/v3/account/projects/stub-projectId/ai/assistants') assert transport.last_request['headers']['authorization'] == 'Bearer test-token' assert transport.last_request['headers']['x-cm-projectid'] == 'test-project' @@ -355,7 +355,7 @@ def test_hub_account_update_project_ai_assistant_request_shape() -> None: client.hub.account.update_project_ai_assistant(project_id="stub-projectId", assistant_id="stub-assistantId") assert transport.last_request is not None assert transport.last_request['method'] == 'PUT' - assert transport.last_request['url'].endswith('/v2/account/projects/stub-projectId/ai/assistants/stub-assistantId') + assert transport.last_request['url'].endswith('/v3/account/projects/stub-projectId/ai/assistants/stub-assistantId') assert transport.last_request['headers']['authorization'] == 'Bearer test-token' assert transport.last_request['headers']['x-cm-projectid'] == 'test-project' @@ -365,7 +365,7 @@ def test_hub_account_delete_project_ai_assistant_request_shape() -> None: client.hub.account.delete_project_ai_assistant(project_id="stub-projectId", assistant_id="stub-assistantId") assert transport.last_request is not None assert transport.last_request['method'] == 'DELETE' - assert transport.last_request['url'].endswith('/v2/account/projects/stub-projectId/ai/assistants/stub-assistantId') + assert transport.last_request['url'].endswith('/v3/account/projects/stub-projectId/ai/assistants/stub-assistantId') assert transport.last_request['headers']['authorization'] == 'Bearer test-token' assert transport.last_request['headers']['x-cm-projectid'] == 'test-project' @@ -375,7 +375,7 @@ def test_hub_account_get_project_ai_usage_request_shape() -> None: client.hub.account.get_project_ai_usage(project_id="stub-projectId") assert transport.last_request is not None assert transport.last_request['method'] == 'GET' - assert transport.last_request['url'].endswith('/v2/account/projects/stub-projectId/ai/usage') + assert transport.last_request['url'].endswith('/v3/account/projects/stub-projectId/ai/usage') assert transport.last_request['headers']['authorization'] == 'Bearer test-token' assert transport.last_request['headers']['x-cm-projectid'] == 'test-project' @@ -385,7 +385,7 @@ def test_hub_account_set_admin_portal_enabled_request_shape() -> None: client.hub.account.set_admin_portal_enabled(project_id="stub-projectId") assert transport.last_request is not None assert transport.last_request['method'] == 'PUT' - assert transport.last_request['url'].endswith('/v2/account/projects/stub-projectId/admin-portal/enabled') + assert transport.last_request['url'].endswith('/v3/account/projects/stub-projectId/admin-portal/enabled') assert transport.last_request['headers']['authorization'] == 'Bearer test-token' assert transport.last_request['headers']['x-cm-projectid'] == 'test-project' @@ -400,7 +400,7 @@ def test_hub_account_check_project_languages_request_shape() -> None: ) assert transport.last_request is not None assert transport.last_request['method'] == 'POST' - assert urlparse(transport.last_request['url']).path == '/v2/account/projects/proj-1/settings/languages/check' + assert urlparse(transport.last_request['url']).path == '/v3/account/projects/proj-1/settings/languages/check' assert json.loads(transport.last_request['body']) == {"defaultLanguage": "en", "languages": ["en", "de"]} assert transport.last_request['headers']['x-cm-accountid'] == 'acc-1' @@ -433,5 +433,5 @@ async def run() -> object: assert asyncio.run(run()) == {"templates": []} assert [(r.method, urlparse(str(r.url)).path, json.loads(r.content)) for r in seen] == [ - ('POST', '/v2/account/projects/proj-1/settings/languages/check', {"languages": ["en"]}), + ('POST', '/v3/account/projects/proj-1/settings/languages/check', {"languages": ["en"]}), ] diff --git a/tests/hub/test_account_mcp.py b/tests/hub/test_account_mcp.py index 20f2063..7b7ecbc 100644 --- a/tests/hub/test_account_mcp.py +++ b/tests/hub/test_account_mcp.py @@ -54,7 +54,7 @@ def handler(request: httpx.Request) -> httpx.Response: } request = seen[0] assert request.method == "POST" - assert request.url.path == "/v2/account/mcp" + assert request.url.path == "/v3/account/mcp" assert request.url.params["toolsets"] == "ai:campaigns,ai:project-context" assert json.loads(request.content) == INIT assert request.headers["accept"] == "application/json, text/event-stream" @@ -104,7 +104,7 @@ def handler(request: httpx.Request) -> httpx.Response: assert result["body"] is None request = seen[0] assert request.method == "GET" - assert request.url.path == "/v2/account/mcp" + assert request.url.path == "/v3/account/mcp" assert request.url.query == b"" assert request.headers["accept"] == "text/event-stream" assert request.headers["mcp-session-id"] == "mcps_1" @@ -122,7 +122,7 @@ def handler(request: httpx.Request) -> httpx.Response: assert result == {"status": 200, "sessionId": None, "body": None, "events": []} assert seen[0].method == "DELETE" - assert seen[0].url.path == "/v2/account/mcp" + assert seen[0].url.path == "/v3/account/mcp" assert seen[0].headers["mcp-session-id"] == "mcps_1" diff --git a/tests/hub/test_account_me.py b/tests/hub/test_account_me.py index 457bb35..275d8d3 100644 --- a/tests/hub/test_account_me.py +++ b/tests/hub/test_account_me.py @@ -47,7 +47,7 @@ def test_get_my_account_user_profile_reads_the_profile_and_phone() -> None: seen: list[httpx.Request] = [] profile = _sync_client(seen, PROFILE).hub.account.get_my_account_user_profile() - assert [(r.method, urlparse(str(r.url)).path) for r in seen] == [("GET", "/v2/account/me")] + assert [(r.method, urlparse(str(r.url)).path) for r in seen] == [("GET", "/v3/account/me")] assert "x-cm-accountid" not in seen[0].headers assert profile["item"]["email"] == "ada@example.test" assert profile["item"]["generalInfo"]["phone"] == "+37060000000" @@ -57,7 +57,7 @@ def test_update_my_account_user_phone_sends_the_phone_in_a_put_body() -> None: seen: list[httpx.Request] = [] _sync_client(seen).hub.account.update_my_account_user_phone(phone="+37060000000") - assert [(r.method, urlparse(str(r.url)).path) for r in seen] == [("PUT", "/v2/account/me/phone")] + assert [(r.method, urlparse(str(r.url)).path) for r in seen] == [("PUT", "/v3/account/me/phone")] assert json.loads(seen[0].content) == {"phone": "+37060000000"} @@ -70,7 +70,7 @@ def test_get_account_collaborators_sends_flat_paging_and_the_project_filter() -> ) url = urlparse(str(seen[0].url)) - assert (seen[0].method, url.path) == ("GET", "/v2/account/collaborators") + assert (seen[0].method, url.path) == ("GET", "/v3/account/collaborators") assert parse_qs(url.query) == {"projectId": ["proj_2"], "pageSize": ["50"], "startingAfter": ["member_20"]} assert "x-cm-accountid" not in seen[0].headers @@ -92,9 +92,9 @@ async def run() -> Any: profile = asyncio.run(run()) assert [(r.method, urlparse(str(r.url)).path) for r in seen] == [ - ("GET", "/v2/account/me"), - ("PUT", "/v2/account/me/phone"), - ("GET", "/v2/account/collaborators"), + ("GET", "/v3/account/me"), + ("PUT", "/v3/account/me/phone"), + ("GET", "/v3/account/collaborators"), ] assert profile["item"]["generalInfo"]["phone"] == "+37060000000" assert json.loads(seen[1].content) == {"phone": "+37060000000"} diff --git a/tests/hub/test_account_project.py b/tests/hub/test_account_project.py index d523435..26a778c 100644 --- a/tests/hub/test_account_project.py +++ b/tests/hub/test_account_project.py @@ -15,7 +15,7 @@ from norbix_python import AsyncNorbix, Norbix -# (method, positional args, keyword body, verb, path after /v2, expected JSON body or None) +# (method, positional args, keyword body, verb, path after /v3, expected JSON body or None) CASES: list[tuple[str, tuple[str, ...], dict[str, Any], str, str, dict[str, Any] | None]] = [ ("update_project_admin_url", ("pr_1",), {"url": "https://admin.example.com"}, "PATCH", "/account/projects/pr_1/settings/admin-url", {"url": "https://admin.example.com"}), @@ -52,7 +52,7 @@ def handler(request: httpx.Request) -> httpx.Response: def _check(request: httpx.Request, verb: str, path: str, body: dict[str, Any] | None) -> None: assert request.method == verb - assert request.url.path == "/v2" + path + assert request.url.path == "/v3" + path assert request.headers["authorization"] == "Bearer test-token" assert request.headers["x-cm-projectid"] == "test-project" if body is None: diff --git a/tests/hub/test_account_token_only.py b/tests/hub/test_account_token_only.py index e980e1b..30e0bb4 100644 --- a/tests/hub/test_account_token_only.py +++ b/tests/hub/test_account_token_only.py @@ -29,39 +29,39 @@ # (module, method, verb, path, positional route ids) CASES: list[tuple[str, str, str, str, dict[str, str]]] = [ - ("account", "get_account_profile", "GET", "/v2/account/profile", {}), - ("account", "update_account_profile", "PUT", "/v2/account/profile", {}), - ("account", "resend_account_verification_token", "GET", "/v2/account/verify/resend", {}), - ("account", "get_account_status", "GET", "/v2/account/status", {}), - ("account", "create_stripe_checkout_session", "POST", "/v2/account/stripe/create-checkout-session", {}), - ("account", "get_stripe_billing_portal_url", "POST", "/v2/account/stripe/get-portal-url", {}), - ("account", "delete_notifications_group", "DELETE", "/v2/account/projects/project_id_1/notifications/settings/group", {'project_id': "project_id_1"}), - ("account", "delete_notifications_tag", "DELETE", "/v2/account/projects/project_id_1/notifications/settings/tag", {'project_id': "project_id_1"}), - ("account", "remove_tag_from_notifications_group", "DELETE", "/v2/account/projects/project_id_1/notifications/settings/group/tag", {'project_id': "project_id_1"}), - ("account", "save_notifications_group", "POST", "/v2/account/projects/project_id_1/notifications/settings/group", {'project_id': "project_id_1"}), - ("account", "save_notifications_tag", "POST", "/v2/account/projects/project_id_1/notifications/settings/tag", {'project_id': "project_id_1"}), - ("account", "create_project", "POST", "/v2/account/projects", {}), - ("account", "delete_project", "DELETE", "/v2/account/projects/project_id_1", {'project_id': "project_id_1"}), - ("account", "get_project", "GET", "/v2/account/projects/project_id_1", {'project_id': "project_id_1"}), - ("account", "get_projects", "GET", "/v2/account/projects", {}), - ("account", "get_project_tokens", "GET", "/v2/account/projects/project_id_1/tokens", {'project_id': "project_id_1"}), - ("account", "update_project_accent_color", "PATCH", "/v2/account/projects/project_id_1/settings/accent-color", {'project_id': "project_id_1"}), - ("account", "update_project_icon", "PATCH", "/v2/account/projects/project_id_1/settings/icon", {'project_id': "project_id_1"}), - ("account", "update_project_logo", "PATCH", "/v2/account/projects/project_id_1/settings/logo", {'project_id': "project_id_1"}), - ("account", "update_project_main_color", "PATCH", "/v2/account/projects/project_id_1/settings/main-color", {'project_id': "project_id_1"}), - ("account", "update_project_allowed_origins", "PATCH", "/v2/account/projects/project_id_1/settings/origins", {'project_id': "project_id_1"}), - ("account", "update_project_default_language", "PATCH", "/v2/account/projects/project_id_1/settings/default-language", {'project_id': "project_id_1"}), - ("account", "update_project_description", "PATCH", "/v2/account/projects/project_id_1/settings/description", {'project_id': "project_id_1"}), - ("account", "disable_project", "PATCH", "/v2/account/projects/project_id_1/disable", {'project_id': "project_id_1"}), - ("account", "enable_project", "PATCH", "/v2/account/projects/project_id_1/enable", {'project_id': "project_id_1"}), - ("account", "check_project_languages", "POST", "/v2/account/projects/project_id_1/settings/languages/check", {'project_id': "project_id_1"}), - ("account", "update_project_languages", "PATCH", "/v2/account/projects/project_id_1/settings/languages", {'project_id': "project_id_1"}), - ("account", "update_project_url", "PATCH", "/v2/account/projects/project_id_1/settings/url", {'project_id': "project_id_1"}), - ("account", "update_project_name", "PATCH", "/v2/account/projects/project_id_1/settings/name", {'project_id': "project_id_1"}), - ("account", "update_project_regions", "PATCH", "/v2/account/projects/project_id_1/settings/regions", {'project_id': "project_id_1"}), - ("account", "send_invite_to_team_member", "POST", "/v2/account/team/member/invite", {}), - ("account", "get_licenses", "GET", "/v2/account/licenses", {}), - ("regions", "update_project_regions", "PATCH", "/v2/account/projects/project_id_1/settings/regions", {'project_id': "project_id_1"}), + ("account", "get_account_profile", "GET", "/v3/account/profile", {}), + ("account", "update_account_profile", "PUT", "/v3/account/profile", {}), + ("account", "resend_account_verification_token", "GET", "/v3/account/verify/resend", {}), + ("account", "get_account_status", "GET", "/v3/account/status", {}), + ("account", "create_stripe_checkout_session", "POST", "/v3/account/stripe/create-checkout-session", {}), + ("account", "get_stripe_billing_portal_url", "POST", "/v3/account/stripe/get-portal-url", {}), + ("account", "delete_notifications_group", "DELETE", "/v3/account/projects/project_id_1/notifications/settings/group", {'project_id': "project_id_1"}), + ("account", "delete_notifications_tag", "DELETE", "/v3/account/projects/project_id_1/notifications/settings/tag", {'project_id': "project_id_1"}), + ("account", "remove_tag_from_notifications_group", "DELETE", "/v3/account/projects/project_id_1/notifications/settings/group/tag", {'project_id': "project_id_1"}), + ("account", "save_notifications_group", "POST", "/v3/account/projects/project_id_1/notifications/settings/group", {'project_id': "project_id_1"}), + ("account", "save_notifications_tag", "POST", "/v3/account/projects/project_id_1/notifications/settings/tag", {'project_id': "project_id_1"}), + ("account", "create_project", "POST", "/v3/account/projects", {}), + ("account", "delete_project", "DELETE", "/v3/account/projects/project_id_1", {'project_id': "project_id_1"}), + ("account", "get_project", "GET", "/v3/account/projects/project_id_1", {'project_id': "project_id_1"}), + ("account", "get_projects", "GET", "/v3/account/projects", {}), + ("account", "get_project_tokens", "GET", "/v3/account/projects/project_id_1/tokens", {'project_id': "project_id_1"}), + ("account", "update_project_accent_color", "PATCH", "/v3/account/projects/project_id_1/settings/accent-color", {'project_id': "project_id_1"}), + ("account", "update_project_icon", "PATCH", "/v3/account/projects/project_id_1/settings/icon", {'project_id': "project_id_1"}), + ("account", "update_project_logo", "PATCH", "/v3/account/projects/project_id_1/settings/logo", {'project_id': "project_id_1"}), + ("account", "update_project_main_color", "PATCH", "/v3/account/projects/project_id_1/settings/main-color", {'project_id': "project_id_1"}), + ("account", "update_project_allowed_origins", "PATCH", "/v3/account/projects/project_id_1/settings/origins", {'project_id': "project_id_1"}), + ("account", "update_project_default_language", "PATCH", "/v3/account/projects/project_id_1/settings/default-language", {'project_id': "project_id_1"}), + ("account", "update_project_description", "PATCH", "/v3/account/projects/project_id_1/settings/description", {'project_id': "project_id_1"}), + ("account", "disable_project", "PATCH", "/v3/account/projects/project_id_1/disable", {'project_id': "project_id_1"}), + ("account", "enable_project", "PATCH", "/v3/account/projects/project_id_1/enable", {'project_id': "project_id_1"}), + ("account", "check_project_languages", "POST", "/v3/account/projects/project_id_1/settings/languages/check", {'project_id': "project_id_1"}), + ("account", "update_project_languages", "PATCH", "/v3/account/projects/project_id_1/settings/languages", {'project_id': "project_id_1"}), + ("account", "update_project_url", "PATCH", "/v3/account/projects/project_id_1/settings/url", {'project_id': "project_id_1"}), + ("account", "update_project_name", "PATCH", "/v3/account/projects/project_id_1/settings/name", {'project_id': "project_id_1"}), + ("account", "update_project_regions", "PATCH", "/v3/account/projects/project_id_1/settings/regions", {'project_id': "project_id_1"}), + ("account", "send_invite_to_team_member", "POST", "/v3/account/team/member/invite", {}), + ("account", "get_licenses", "GET", "/v3/account/licenses", {}), + ("regions", "update_project_regions", "PATCH", "/v3/account/projects/project_id_1/settings/regions", {'project_id': "project_id_1"}), ] IDS = [f"{module}.{method}" for module, method, *_ in CASES] @@ -126,11 +126,11 @@ async def run() -> None: # (module, method, verb, path, request fields) PUBLIC_CASES: list[tuple[str, str, str, str, dict[str, str]]] = [ - ("account", "create_account", "POST", "/v2/account", {"email": "ada@example.test", "password": "pw", "displayName": "Ada"}), - ("account", "create_team_member_from_invitation", "POST", "/v2/account/team/member", {"token": "invite-1", "password": "pw", "displayName": "Ada"}), - ("account", "get_account_regions", "GET", "/v2/account/regions", {}), - ("regions", "list", "GET", "/v2/account/regions", {}), - ("account", "verify_account", "GET", "/v2/account/verify", {"accountId": "acc-1", "token": "verify-1"}), + ("account", "create_account", "POST", "/v3/account", {"email": "ada@example.test", "password": "pw", "displayName": "Ada"}), + ("account", "create_team_member_from_invitation", "POST", "/v3/account/team/member", {"token": "invite-1", "password": "pw", "displayName": "Ada"}), + ("account", "get_account_regions", "GET", "/v3/account/regions", {}), + ("regions", "list", "GET", "/v3/account/regions", {}), + ("account", "verify_account", "GET", "/v3/account/verify", {"accountId": "acc-1", "token": "verify-1"}), ] PUBLIC_IDS = [f"{module}.{method}" for module, method, *_ in PUBLIC_CASES] diff --git a/tests/hub/test_ai.py b/tests/hub/test_ai.py index 4f8cd90..e332b2e 100644 --- a/tests/hub/test_ai.py +++ b/tests/hub/test_ai.py @@ -137,7 +137,7 @@ def test_hub_ai_get_embedding_integrations_request_shape() -> None: client.hub.ai.get_embedding_integrations() assert transport.last_request is not None assert transport.last_request['method'] == 'GET' - assert transport.last_request['url'].endswith('/v2/ai/integrations/embeddings') + assert transport.last_request['url'].endswith('/v3/ai/integrations/embeddings') assert transport.last_request['headers']['authorization'] == 'Bearer test-token' assert transport.last_request['headers']['x-cm-projectid'] == 'test-project' @@ -147,7 +147,7 @@ def test_hub_ai_save_embedding_integration_request_shape() -> None: client.hub.ai.save_embedding_integration() assert transport.last_request is not None assert transport.last_request['method'] == 'POST' - assert transport.last_request['url'].endswith('/v2/ai/integrations/embeddings') + assert transport.last_request['url'].endswith('/v3/ai/integrations/embeddings') assert transport.last_request['headers']['authorization'] == 'Bearer test-token' assert transport.last_request['headers']['x-cm-projectid'] == 'test-project' @@ -157,7 +157,7 @@ def test_hub_ai_get_embedding_integration_request_shape() -> None: client.hub.ai.get_embedding_integration(id="stub-Id") assert transport.last_request is not None assert transport.last_request['method'] == 'GET' - assert transport.last_request['url'].endswith('/v2/ai/integrations/embeddings/stub-Id') + assert transport.last_request['url'].endswith('/v3/ai/integrations/embeddings/stub-Id') assert transport.last_request['headers']['authorization'] == 'Bearer test-token' assert transport.last_request['headers']['x-cm-projectid'] == 'test-project' @@ -167,7 +167,7 @@ def test_hub_ai_delete_embedding_integration_request_shape() -> None: client.hub.ai.delete_embedding_integration(id="stub-Id") assert transport.last_request is not None assert transport.last_request['method'] == 'DELETE' - assert transport.last_request['url'].endswith('/v2/ai/integrations/embeddings/stub-Id') + assert transport.last_request['url'].endswith('/v3/ai/integrations/embeddings/stub-Id') assert transport.last_request['headers']['authorization'] == 'Bearer test-token' assert transport.last_request['headers']['x-cm-projectid'] == 'test-project' @@ -177,7 +177,7 @@ def test_hub_ai_test_embedding_integration_request_shape() -> None: client.hub.ai.test_embedding_integration(id="stub-Id") assert transport.last_request is not None assert transport.last_request['method'] == 'POST' - assert transport.last_request['url'].endswith('/v2/ai/integrations/embeddings/stub-Id/test') + assert transport.last_request['url'].endswith('/v3/ai/integrations/embeddings/stub-Id/test') assert transport.last_request['headers']['authorization'] == 'Bearer test-token' assert transport.last_request['headers']['x-cm-projectid'] == 'test-project' @@ -187,7 +187,7 @@ def test_hub_ai_set_llm_integration_as_default_request_shape() -> None: client.hub.ai.set_llm_integration_as_default(id="stub-Id") assert transport.last_request is not None assert transport.last_request['method'] == 'PUT' - assert transport.last_request['url'].endswith('/v2/ai/integrations/llms/stub-Id/default') + assert transport.last_request['url'].endswith('/v3/ai/integrations/llms/stub-Id/default') assert transport.last_request['headers']['authorization'] == 'Bearer test-token' assert transport.last_request['headers']['x-cm-projectid'] == 'test-project' diff --git a/tests/hub/test_database.py b/tests/hub/test_database.py index 504f1ee..79cbdc8 100644 --- a/tests/hub/test_database.py +++ b/tests/hub/test_database.py @@ -389,7 +389,7 @@ def test_hub_database_reveal_managed_flex_connection_string_request_shape() -> N # transport; nothing leaves the process. -DB = "/v2/database" +DB = "/v3/database" COLL = "products" REC = "rec_1" SCHEMA = "sch_1" diff --git a/tests/hub/test_database_last_wave.py b/tests/hub/test_database_last_wave.py index c3acefe..c922369 100644 --- a/tests/hub/test_database_last_wave.py +++ b/tests/hub/test_database_last_wave.py @@ -188,7 +188,7 @@ def test_every_hub_database_method_sends_its_documented_verb_and_path() -> None: fn(*args) assert transport.last_request is not None assert transport.last_request["method"] == verb, name - pattern = "^" + _TOKEN.sub("[^/]+", path.replace("{version}", "v2")) + "$" + pattern = "^" + _TOKEN.sub("[^/]+", path.replace("{version}", "v3")) + "$" sent = urlparse(transport.last_request["url"]).path assert re.match(pattern, sent), (name, sent) for arg in args: @@ -211,12 +211,12 @@ def test_async_hub_database_has_the_same_methods_as_sync() -> None: @pytest.mark.parametrize( ("call", "verb", "path"), [ - (lambda db: db.create_collection_import(schemaId="sch_1", file={"path": "imports/a.csv"}), "POST", "/v2/database/imports"), - (lambda db: db.get_collection_imports(), "GET", "/v2/database/imports"), - (lambda db: db.get_collection_import("imp_1"), "GET", "/v2/database/imports/imp_1"), - (lambda db: db.delete_collection_import("imp_1"), "DELETE", "/v2/database/imports/imp_1"), - (lambda db: db.request_import_upload_url(fileName="a.csv"), "POST", "/v2/database/imports/upload-url"), - (lambda db: db.analyze_import_file(file={"path": "imports/a.csv"}), "POST", "/v2/database/imports/analyze"), + (lambda db: db.create_collection_import(schemaId="sch_1", file={"path": "imports/a.csv"}), "POST", "/v3/database/imports"), + (lambda db: db.get_collection_imports(), "GET", "/v3/database/imports"), + (lambda db: db.get_collection_import("imp_1"), "GET", "/v3/database/imports/imp_1"), + (lambda db: db.delete_collection_import("imp_1"), "DELETE", "/v3/database/imports/imp_1"), + (lambda db: db.request_import_upload_url(fileName="a.csv"), "POST", "/v3/database/imports/upload-url"), + (lambda db: db.analyze_import_file(file={"path": "imports/a.csv"}), "POST", "/v3/database/imports/analyze"), ], ) def test_collection_import_methods(call: Any, verb: str, path: str) -> None: @@ -237,7 +237,7 @@ def test_update_many_records_sends_all_records_in_the_body() -> None: ) assert transport.last_request is not None assert transport.last_request["method"] == "PUT" - assert urlparse(transport.last_request["url"]).path == "/v2/database/collections/products/many" + assert urlparse(transport.last_request["url"]).path == "/v3/database/collections/products/many" assert json.loads(transport.last_request["body"]) == { "filter": "{}", "update": '{"status": "archived"}', @@ -259,7 +259,7 @@ def test_delete_many_records_sends_all_records_in_the_query() -> None: assert transport.last_request is not None url = urlparse(transport.last_request["url"]) assert transport.last_request["method"] == "DELETE" - assert url.path == "/v2/database/collections/products/many" + assert url.path == "/v3/database/collections/products/many" assert parse_qs(url.query) == {"filter": ["{}"], "allRecords": ["true"]} @@ -326,7 +326,7 @@ def test_rename_schema_sends_only_the_new_name() -> None: client.hub.database.rename_database_schema("sch_1", title="Products") assert transport.last_request is not None assert transport.last_request["method"] == "PUT" - assert urlparse(transport.last_request["url"]).path == "/v2/database/schemas/sch_1/rename" + assert urlparse(transport.last_request["url"]).path == "/v3/database/schemas/sch_1/rename" assert json.loads(transport.last_request["body"]) == {"title": "Products"} @@ -359,12 +359,12 @@ def test_delete_schema_used_by_an_aggregate_names_the_aggregates() -> None: @pytest.mark.parametrize( ("call", "verb", "path"), [ - (lambda db: db.get_schema_triggers(), "GET", "/v2/database/schemas/triggers"), - (lambda db: db.get_schema_trigger("trg_1"), "GET", "/v2/database/schemas/triggers/trg_1"), - (lambda db: db.save_schema_trigger(schemaId="sch_1"), "POST", "/v2/database/schemas/triggers"), - (lambda db: db.enable_schema_trigger("trg_1"), "PATCH", "/v2/database/schemas/triggers/trg_1/enable"), - (lambda db: db.disable_schema_trigger("trg_1"), "PATCH", "/v2/database/schemas/triggers/trg_1/disable"), - (lambda db: db.delete_schema_trigger("trg_1"), "DELETE", "/v2/database/schemas/triggers/trg_1"), + (lambda db: db.get_schema_triggers(), "GET", "/v3/database/schemas/triggers"), + (lambda db: db.get_schema_trigger("trg_1"), "GET", "/v3/database/schemas/triggers/trg_1"), + (lambda db: db.save_schema_trigger(schemaId="sch_1"), "POST", "/v3/database/schemas/triggers"), + (lambda db: db.enable_schema_trigger("trg_1"), "PATCH", "/v3/database/schemas/triggers/trg_1/enable"), + (lambda db: db.disable_schema_trigger("trg_1"), "PATCH", "/v3/database/schemas/triggers/trg_1/disable"), + (lambda db: db.delete_schema_trigger("trg_1"), "DELETE", "/v3/database/schemas/triggers/trg_1"), ], ) def test_schema_trigger_calls_carry_the_client_env(call: Any, verb: str, path: str) -> None: @@ -431,7 +431,7 @@ def test_taxonomy_tree_with_terms_sends_include_terms() -> None: client.hub.database.get_database_taxonomy_tree(includeTerms=True) assert transport.last_request is not None url = urlparse(transport.last_request["url"]) - assert url.path == "/v2/database/taxonomies/tree" + assert url.path == "/v3/database/taxonomies/tree" assert parse_qs(url.query) == {"includeTerms": ["true"]} diff --git a/tests/hub/test_email_routes.py b/tests/hub/test_email_routes.py index 1e3ac4b..a3a6d08 100644 --- a/tests/hub/test_email_routes.py +++ b/tests/hub/test_email_routes.py @@ -36,301 +36,301 @@ ( "one_click_unsubscribe", "POST", - "/v2/email/one-click-unsubscribe", + "/v3/email/one-click-unsubscribe", lambda c: c.hub.email.one_click_unsubscribe(), ), ( "get_email_preferences_by_link", "GET", - "/v2/email/preferences", + "/v3/email/preferences", lambda c: c.hub.email.get_email_preferences_by_link(), ), ( "get_email_campaigns", "GET", - "/v2/notifications/email/campaigns", + "/v3/notifications/email/campaigns", lambda c: c.hub.notifications.get_email_campaigns(), ), ( "create_email_campaign", "POST", - "/v2/notifications/email/campaigns", + "/v3/notifications/email/campaigns", lambda c: c.hub.notifications.create_email_campaign(), ), ( "delete_email_campaign", "DELETE", - f"/v2/notifications/email/campaigns/{ITEM_ID}", + f"/v3/notifications/email/campaigns/{ITEM_ID}", lambda c: c.hub.notifications.delete_email_campaign(id=ITEM_ID), ), ( "stop_email_campaign", "POST", - f"/v2/notifications/email/campaigns/{ITEM_ID}/stop", + f"/v3/notifications/email/campaigns/{ITEM_ID}/stop", lambda c: c.hub.notifications.stop_email_campaign(id=ITEM_ID), ), ( "get_email_campaign", "GET", - f"/v2/notifications/email/campaigns/{ITEM_ID}", + f"/v3/notifications/email/campaigns/{ITEM_ID}", lambda c: c.hub.notifications.get_email_campaign(id=ITEM_ID), ), ( "get_email_campaign_batches", "GET", - f"/v2/notifications/email/campaigns/{ITEM_ID}/batches", + f"/v3/notifications/email/campaigns/{ITEM_ID}/batches", lambda c: c.hub.notifications.get_email_campaign_batches(id=ITEM_ID), ), ( "get_email_campaign_batch_notifications", "GET", - f"/v2/notifications/email/campaigns/{ITEM_ID}/batches/{BATCH_ID}", + f"/v3/notifications/email/campaigns/{ITEM_ID}/batches/{BATCH_ID}", lambda c: c.hub.notifications.get_email_campaign_batch_notifications(id=ITEM_ID, batch_id=BATCH_ID), ), ( "get_email_campaign_batch_notification", "GET", - f"/v2/notifications/email/campaigns/{ITEM_ID}/batches/{BATCH_ID}/{NOTIFICATION_ID}", + f"/v3/notifications/email/campaigns/{ITEM_ID}/batches/{BATCH_ID}/{NOTIFICATION_ID}", lambda c: c.hub.notifications.get_email_campaign_batch_notification(id=ITEM_ID, batch_id=BATCH_ID, notification_id=NOTIFICATION_ID), ), ( "get_email_campaign_statistics", "GET", - f"/v2/notifications/email/campaigns/{ITEM_ID}/stats", + f"/v3/notifications/email/campaigns/{ITEM_ID}/stats", lambda c: c.hub.notifications.get_email_campaign_statistics(id=ITEM_ID), ), ( "disable_email", "PUT", - "/v2/notifications/email/disable", + "/v3/notifications/email/disable", lambda c: c.hub.notifications.disable_email(), ), ( "get_email_disable_dependencies", "GET", - "/v2/notifications/email/disable-dependencies", + "/v3/notifications/email/disable-dependencies", lambda c: c.hub.notifications.get_email_disable_dependencies(), ), ( "enable_email", "PUT", - "/v2/notifications/email/enable", + "/v3/notifications/email/enable", lambda c: c.hub.notifications.enable_email(), ), ( "get_email_footers", "GET", - "/v2/notifications/email/footers", + "/v3/notifications/email/footers", lambda c: c.hub.notifications.get_email_footers(), ), ( "save_email_footer", "POST", - "/v2/notifications/email/footers", + "/v3/notifications/email/footers", lambda c: c.hub.notifications.save_email_footer(), ), ( "delete_email_footer", "DELETE", - f"/v2/notifications/email/footers/{ITEM_ID}", + f"/v3/notifications/email/footers/{ITEM_ID}", lambda c: c.hub.notifications.delete_email_footer(id=ITEM_ID), ), ( "get_email_footer", "GET", - f"/v2/notifications/email/footers/{ITEM_ID}", + f"/v3/notifications/email/footers/{ITEM_ID}", lambda c: c.hub.notifications.get_email_footer(id=ITEM_ID), ), ( "get_email_integrations", "GET", - "/v2/notifications/email/integrations", + "/v3/notifications/email/integrations", lambda c: c.hub.notifications.get_email_integrations(), ), ( "save_email_integration", "POST", - "/v2/notifications/email/integrations", + "/v3/notifications/email/integrations", lambda c: c.hub.notifications.save_email_integration(), ), ( "confirm_email_integration_human_delivery", "POST", - "/v2/notifications/email/integrations/confirm-human-delivery", + "/v3/notifications/email/integrations/confirm-human-delivery", lambda c: c.hub.notifications.confirm_email_integration_human_delivery(), ), ( "check_email_integration_domain_health", "POST", - "/v2/notifications/email/integrations/domain-health", + "/v3/notifications/email/integrations/domain-health", lambda c: c.hub.notifications.check_email_integration_domain_health(), ), ( "test_email_integration", "POST", - "/v2/notifications/email/integrations/test", + "/v3/notifications/email/integrations/test", lambda c: c.hub.notifications.test_email_integration(), ), ( "delete_email_integration", "DELETE", - f"/v2/notifications/email/integrations/{ITEM_ID}", + f"/v3/notifications/email/integrations/{ITEM_ID}", lambda c: c.hub.notifications.delete_email_integration(id=ITEM_ID), ), ( "set_emails_integration_as_default", "PUT", - f"/v2/notifications/email/integrations/{ITEM_ID}/default", + f"/v3/notifications/email/integrations/{ITEM_ID}/default", lambda c: c.hub.notifications.set_emails_integration_as_default(id=ITEM_ID), ), ( "disable_email_integration", "PUT", - f"/v2/notifications/email/integrations/{ITEM_ID}/disable", + f"/v3/notifications/email/integrations/{ITEM_ID}/disable", lambda c: c.hub.notifications.disable_email_integration(id=ITEM_ID), ), ( "enable_email_integration", "PUT", - f"/v2/notifications/email/integrations/{ITEM_ID}/enable", + f"/v3/notifications/email/integrations/{ITEM_ID}/enable", lambda c: c.hub.notifications.enable_email_integration(id=ITEM_ID), ), ( "get_email_integration", "GET", - f"/v2/notifications/email/integrations/{ITEM_ID}", + f"/v3/notifications/email/integrations/{ITEM_ID}", lambda c: c.hub.notifications.get_email_integration(id=ITEM_ID), ), ( "preview_email_notification", "GET", - "/v2/notifications/email/preview", + "/v3/notifications/email/preview", lambda c: c.hub.notifications.preview_email_notification(), ), ( "get_email_settings", "GET", - "/v2/notifications/email/settings", + "/v3/notifications/email/settings", lambda c: c.hub.notifications.get_email_settings(), ), ( "get_email_signatures", "GET", - "/v2/notifications/email/signatures", + "/v3/notifications/email/signatures", lambda c: c.hub.notifications.get_email_signatures(), ), ( "save_email_signature", "POST", - "/v2/notifications/email/signatures", + "/v3/notifications/email/signatures", lambda c: c.hub.notifications.save_email_signature(), ), ( "delete_email_signature", "DELETE", - f"/v2/notifications/email/signatures/{ITEM_ID}", + f"/v3/notifications/email/signatures/{ITEM_ID}", lambda c: c.hub.notifications.delete_email_signature(id=ITEM_ID), ), ( "get_email_signature", "GET", - f"/v2/notifications/email/signatures/{ITEM_ID}", + f"/v3/notifications/email/signatures/{ITEM_ID}", lambda c: c.hub.notifications.get_email_signature(id=ITEM_ID), ), ( "get_system_email_templates", "GET", - "/v2/notifications/email/system-templates", + "/v3/notifications/email/system-templates", lambda c: c.hub.notifications.get_system_email_templates(), ), ( "get_system_email_template", "GET", - f"/v2/notifications/email/system-templates/{ITEM_ID}", + f"/v3/notifications/email/system-templates/{ITEM_ID}", lambda c: c.hub.notifications.get_system_email_template(id=ITEM_ID), ), ( "get_email_templates", "GET", - "/v2/notifications/email/templates", + "/v3/notifications/email/templates", lambda c: c.hub.notifications.get_email_templates(), ), ( "create_email_template", "POST", - "/v2/notifications/email/templates", + "/v3/notifications/email/templates", lambda c: c.hub.notifications.create_email_template(), ), ( "update_email_template", "PUT", - "/v2/notifications/email/templates", + "/v3/notifications/email/templates", lambda c: c.hub.notifications.update_email_template(), ), ( "attach_file_to_template", "POST", - "/v2/notifications/email/templates/attachments", + "/v3/notifications/email/templates/attachments", lambda c: c.hub.notifications.attach_file_to_template(), ), ( "get_mjml", "POST", - "/v2/notifications/email/templates/mjml", + "/v3/notifications/email/templates/mjml", lambda c: c.hub.notifications.get_mjml(), ), ( "delete_email_template", "DELETE", - f"/v2/notifications/email/templates/{ITEM_ID}", + f"/v3/notifications/email/templates/{ITEM_ID}", lambda c: c.hub.notifications.delete_email_template(id=ITEM_ID), ), ( "archive_email_template", "PUT", - f"/v2/notifications/email/templates/{ITEM_ID}/archive", + f"/v3/notifications/email/templates/{ITEM_ID}/archive", lambda c: c.hub.notifications.archive_email_template(id=ITEM_ID), ), ( "clone_email_template", "POST", - f"/v2/notifications/email/templates/{ITEM_ID}/clone", + f"/v3/notifications/email/templates/{ITEM_ID}/clone", lambda c: c.hub.notifications.clone_email_template(id=ITEM_ID), ), ( "un_archive_email_template", "PUT", - f"/v2/notifications/email/templates/{ITEM_ID}/unarchive", + f"/v3/notifications/email/templates/{ITEM_ID}/unarchive", lambda c: c.hub.notifications.un_archive_email_template(id=ITEM_ID), ), ( "get_email_template", "GET", - f"/v2/notifications/email/templates/{ITEM_ID}", + f"/v3/notifications/email/templates/{ITEM_ID}", lambda c: c.hub.notifications.get_email_template(id=ITEM_ID), ), ( "get_email_template_available_tokens", "GET", - f"/v2/notifications/email/templates/{ITEM_ID}/tokens", + f"/v3/notifications/email/templates/{ITEM_ID}/tokens", lambda c: c.hub.notifications.get_email_template_available_tokens(id=ITEM_ID), ), ( "save_email_validation_integration", "POST", - "/v2/notifications/email/validation/integrations", + "/v3/notifications/email/validation/integrations", lambda c: c.hub.notifications.save_email_validation_integration(), ), ( "test_email_validation_integration", "POST", - "/v2/notifications/email/validation/integrations/test", + "/v3/notifications/email/validation/integrations/test", lambda c: c.hub.notifications.test_email_validation_integration(), ), ( "get_email_campaign_messages", "GET", - f"/v2/notifications/emails/campaigns/{CAMPAIGN_ID}/messages", + f"/v3/notifications/emails/campaigns/{CAMPAIGN_ID}/messages", lambda c: c.hub.notifications.get_email_campaign_messages(campaign_id=CAMPAIGN_ID), ), ] @@ -402,7 +402,7 @@ def test_email_preferences_by_link_needs_no_sign_in(api_key: str | None, want_au assert len(seen) == 1 url = urlparse(str(seen[0].url)) assert seen[0].method == "GET" - assert url.path == "/v2/email/preferences" + assert url.path == "/v3/email/preferences" assert parse_qs(url.query) == {"token": [TOKEN]} assert seen[0].headers.get("Authorization") == want_auth @@ -424,7 +424,7 @@ async def run() -> None: asyncio.run(run()) assert len(seen) == 1 - assert urlparse(str(seen[0].url)).path == "/v2/email/preferences" + assert urlparse(str(seen[0].url)).path == "/v3/email/preferences" assert seen[0].headers.get("Authorization") is None @@ -456,7 +456,7 @@ def test_one_click_unsubscribe_needs_no_sign_in() -> None: assert len(seen) == 1 assert seen[0].method == "POST" - assert urlparse(str(seen[0].url)).path == "/v2/email/one-click-unsubscribe" + assert urlparse(str(seen[0].url)).path == "/v3/email/one-click-unsubscribe" assert seen[0].headers.get("Authorization") is None @@ -491,7 +491,7 @@ def test_create_email_campaign_sends_the_provider_integration_id_nested() -> Non assert transport.last_request is not None assert transport.last_request["method"] == "POST" - assert urlparse(transport.last_request["url"]).path == "/v2/notifications/email/campaigns" + assert urlparse(transport.last_request["url"]).path == "/v3/notifications/email/campaigns" assert json.loads(transport.last_request["body"]) == { "campaign": {"templateId": "tpl_1", "integrationId": "int_1", "source": "allUsers"} } diff --git a/tests/hub/test_module_enable_disable.py b/tests/hub/test_module_enable_disable.py index 3253dac..2481679 100644 --- a/tests/hub/test_module_enable_disable.py +++ b/tests/hub/test_module_enable_disable.py @@ -16,7 +16,7 @@ from ..helpers import make_client -# (module attribute, method name, path after /v2) +# (module attribute, method name, path after /v3) CASES = [ ("database", "enable_database", "/database/enable"), ("database", "disable_database", "/database/disable"), @@ -45,7 +45,7 @@ def test_sync_module_switch_uses_put(module: str, method: str, path: str) -> Non getattr(getattr(client.hub, module), method)() assert transport.last_request is not None sent = httpx.URL(transport.last_request["url"]) - assert (transport.last_request["method"], sent.path) == ("PUT", "/v2" + path) + assert (transport.last_request["method"], sent.path) == ("PUT", "/v3" + path) @pytest.mark.parametrize(("module", "method", "path"), CASES, ids=[c[1] for c in CASES]) @@ -65,4 +65,4 @@ async def run() -> None: await getattr(getattr(client.hub, module), method)() asyncio.run(run()) - assert [(r.method, r.url.path) for r in seen] == [("PUT", "/v2" + path)] + assert [(r.method, r.url.path) for r in seen] == [("PUT", "/v3" + path)] diff --git a/tests/hub/test_notifications_preview.py b/tests/hub/test_notifications_preview.py index e5cabb4..ac4909f 100644 --- a/tests/hub/test_notifications_preview.py +++ b/tests/hub/test_notifications_preview.py @@ -26,17 +26,17 @@ PREVIEW_CASES: list[PreviewCase] = [ ( "push", - "/v2/notifications/push/preview", + "/v3/notifications/push/preview", lambda m: m.preview_push_notification(hash=HASH), ), ( "email", - "/v2/notifications/email/preview", + "/v3/notifications/email/preview", lambda m: m.preview_email_notification(hash=HASH), ), ( "sms", - "/v2/notifications/sms/preview", + "/v3/notifications/sms/preview", lambda m: m.preview_sms_notification(hash=HASH), ), ] diff --git a/tests/hub/test_push.py b/tests/hub/test_push.py index 1c5b3d3..691665e 100644 --- a/tests/hub/test_push.py +++ b/tests/hub/test_push.py @@ -28,7 +28,7 @@ INTEGRATION_ID = "int_1" DEVICE_ID = "pnd_1" -BASE = "/v2/notifications/push" +BASE = "/v3/notifications/push" # name, verb, expected path, call PushCase = tuple[str, str, str, Callable[[Any], Any]] diff --git a/tests/hub/test_scheduler.py b/tests/hub/test_scheduler.py index 859adaf..34b1774 100644 --- a/tests/hub/test_scheduler.py +++ b/tests/hub/test_scheduler.py @@ -26,7 +26,7 @@ INITIATOR_USER_ID = "usr_1" EMAIL_TEMPLATE_ID = "etpl_1" -BASE = "/v2/scheduler" +BASE = "/v3/scheduler" # A complete save request: the initiator, the schedule, and an email campaign # task sent to all users. EmailCampaign is the only task type the gateway runs. diff --git a/tests/hub/test_sms.py b/tests/hub/test_sms.py index c085e44..f868eb3 100644 --- a/tests/hub/test_sms.py +++ b/tests/hub/test_sms.py @@ -33,7 +33,7 @@ INTEGRATION_ID = "int_1" CAMPAIGN_TIME = 1_900_000_000 # unix seconds, UTC — a future time -BASE = "/v2/notifications/sms" +BASE = "/v3/notifications/sms" # name, verb, expected path, call SmsCase = tuple[str, str, str, Callable[[Any], Any]] diff --git a/tests/hub/test_triggers.py b/tests/hub/test_triggers.py index 5b314a9..beb05e0 100644 --- a/tests/hub/test_triggers.py +++ b/tests/hub/test_triggers.py @@ -39,7 +39,7 @@ def test_get_triggers_needing_attention_hits_the_route_with_query_values() -> No assert transport.last_request is not None assert transport.last_request["method"] == "GET" url = urlparse(transport.last_request["url"]) - assert url.path == "/v2/triggers/attention" + assert url.path == "/v3/triggers/attention" assert parse_qs(url.query) == {"triggerType": ["Schema"]} assert transport.last_request["body"] == "" assert transport.last_request["headers"]["x-cm-projectid"] == "test-project" @@ -67,17 +67,17 @@ async def run() -> Any: assert result == {"items": []} assert [(r.method, urlparse(str(r.url)).path, urlparse(str(r.url)).query) for r in seen] == [ - ("GET", "/v2/triggers/attention", "triggerType=Files"), + ("GET", "/v3/triggers/attention", "triggerType=Files"), ] # name, expected path, call — every trigger save in the hub. SaveCase = tuple[str, str, Callable[[Any, dict[str, Any]], Any]] TRIGGER_SAVES: list[SaveCase] = [ - ("save_schema_trigger", "/v2/database/schemas/triggers", lambda c, b: c.hub.database.save_schema_trigger(**b)), - ("save_files_trigger", "/v2/files/triggers", lambda c, b: c.hub.files.save_files_trigger(**b)), - ("save_membership_trigger", "/v2/membership/triggers", lambda c, b: c.hub.membership.save_membership_trigger(**b)), - ("save_payments_trigger", "/v2/payments/triggers", lambda c, b: c.hub.payments.save_payments_trigger(**b)), + ("save_schema_trigger", "/v3/database/schemas/triggers", lambda c, b: c.hub.database.save_schema_trigger(**b)), + ("save_files_trigger", "/v3/files/triggers", lambda c, b: c.hub.files.save_files_trigger(**b)), + ("save_membership_trigger", "/v3/membership/triggers", lambda c, b: c.hub.membership.save_membership_trigger(**b)), + ("save_payments_trigger", "/v3/payments/triggers", lambda c, b: c.hub.payments.save_payments_trigger(**b)), ] diff --git a/tests/test_default_version.py b/tests/test_default_version.py new file mode 100644 index 0000000..4b26a01 --- /dev/null +++ b/tests/test_default_version.py @@ -0,0 +1,32 @@ +from __future__ import annotations + +import pytest + +from norbix_python.client import DEFAULT_VERSION, _build_config + +"""API and Hub default to v3, the gateway's current version. NORBIX_API_VERSION +/ NORBIX_HUB_VERSION and the constructor arguments still override it.""" + + +def _build(**overrides: str) -> object: + args: dict[str, object] = dict( + project_id="proj_1", api_key="k", bearer_token=None, account_id=None, env=None, + region=None, base_url_api=None, base_url_hub=None, api_version=None, + hub_version=None, timeout=None, default_headers=None, client_name="Norbix", + ) + args.update(overrides) + return _build_config(**args) # type: ignore[arg-type] + + +def test_default_version_is_v3(monkeypatch: pytest.MonkeyPatch) -> None: + monkeypatch.delenv("NORBIX_API_VERSION", raising=False) + monkeypatch.delenv("NORBIX_HUB_VERSION", raising=False) + cfg = _build() + assert DEFAULT_VERSION == "v3" + assert (cfg.api_version, cfg.hub_version) == ("v3", "v3") # type: ignore[attr-defined] + + +def test_env_and_arguments_still_override(monkeypatch: pytest.MonkeyPatch) -> None: + monkeypatch.setenv("NORBIX_API_VERSION", "v2") + cfg = _build(hub_version="v4") + assert (cfg.api_version, cfg.hub_version) == ("v2", "v4") # type: ignore[attr-defined] diff --git a/tests/test_files_routes.py b/tests/test_files_routes.py index ec5d9be..ba59af1 100644 --- a/tests/test_files_routes.py +++ b/tests/test_files_routes.py @@ -45,14 +45,14 @@ def test_enable_files() -> None: client, transport = make_client() client.hub.files.enable_files() method, path, _, _ = _sent(transport) - assert (method, path) == ("PUT", "/v2/files/enable") + assert (method, path) == ("PUT", "/v3/files/enable") def test_disable_files() -> None: client, transport = make_client() client.hub.files.disable_files() method, path, _, _ = _sent(transport) - assert (method, path) == ("PUT", "/v2/files/disable") + assert (method, path) == ("PUT", "/v3/files/disable") # --- hub: browsing ----------------------------------------------------------- @@ -62,7 +62,7 @@ def test_get_folder_files() -> None: client, transport = make_client() client.hub.files.get_folder_files(filesIntegrationId=INTEGRATION_ID, path="invoices/") method, path, query, _ = _sent(transport) - assert (method, path) == ("GET", "/v2/files/folder") + assert (method, path) == ("GET", "/v3/files/folder") assert INTEGRATION_ID in query @@ -70,7 +70,7 @@ def test_get_file() -> None: client, transport = make_client() client.hub.files.get_file(filesIntegrationId=INTEGRATION_ID, path="invoices/invoice.pdf") method, path, query, _ = _sent(transport) - assert (method, path) == ("GET", "/v2/files/item") + assert (method, path) == ("GET", "/v3/files/item") assert INTEGRATION_ID in query @@ -78,7 +78,7 @@ def test_get_file_by_id() -> None: client, transport = make_client() client.hub.files.get_file_by_id(INTEGRATION_ID, "nbfl_7hK2abc") method, path, query, _ = _sent(transport) - assert (method, path) == ("GET", "/v2/files/item/by-id") + assert (method, path) == ("GET", "/v3/files/item/by-id") assert parse_qs(query) == {"filesIntegrationId": [INTEGRATION_ID], "id": ["nbfl_7hK2abc"]} @@ -89,14 +89,14 @@ def test_get_files_integrations() -> None: client, transport = make_client() client.hub.files.get_files_integrations() method, path, _, _ = _sent(transport) - assert (method, path) == ("GET", "/v2/files/integrations") + assert (method, path) == ("GET", "/v3/files/integrations") def test_get_files_integration() -> None: client, transport = make_client() client.hub.files.get_files_integration(id=INTEGRATION_ID) method, path, _, _ = _sent(transport) - assert (method, path) == ("GET", f"/v2/files/integrations/{INTEGRATION_ID}") + assert (method, path) == ("GET", f"/v3/files/integrations/{INTEGRATION_ID}") def test_save_files_integration() -> None: @@ -105,7 +105,7 @@ def test_save_files_integration() -> None: integration={"integrationName": "Invoices bucket", "bucketName": "norbix-invoices"} ) method, path, _, body = _sent(transport) - assert (method, path) == ("POST", "/v2/files/integrations") + assert (method, path) == ("POST", "/v3/files/integrations") assert body["integration"]["bucketName"] == "norbix-invoices" @@ -113,35 +113,35 @@ def test_delete_files_integration() -> None: client, transport = make_client() client.hub.files.delete_files_integration(id=INTEGRATION_ID) method, path, _, _ = _sent(transport) - assert (method, path) == ("DELETE", f"/v2/files/integrations/{INTEGRATION_ID}") + assert (method, path) == ("DELETE", f"/v3/files/integrations/{INTEGRATION_ID}") def test_enable_files_integration() -> None: client, transport = make_client() client.hub.files.enable_files_integration(id=INTEGRATION_ID) method, path, _, _ = _sent(transport) - assert (method, path) == ("PUT", f"/v2/files/integrations/{INTEGRATION_ID}/enable") + assert (method, path) == ("PUT", f"/v3/files/integrations/{INTEGRATION_ID}/enable") def test_disable_files_integration() -> None: client, transport = make_client() client.hub.files.disable_files_integration(id=INTEGRATION_ID) method, path, _, _ = _sent(transport) - assert (method, path) == ("PUT", f"/v2/files/integrations/{INTEGRATION_ID}/disable") + assert (method, path) == ("PUT", f"/v3/files/integrations/{INTEGRATION_ID}/disable") def test_set_files_integration_as_default() -> None: client, transport = make_client() client.hub.files.set_files_integration_as_default(id=INTEGRATION_ID) method, path, _, _ = _sent(transport) - assert (method, path) == ("PUT", f"/v2/files/integrations/{INTEGRATION_ID}/default") + assert (method, path) == ("PUT", f"/v3/files/integrations/{INTEGRATION_ID}/default") def test_test_files_integration() -> None: client, transport = make_client() client.hub.files.test_files_integration(integrationId=INTEGRATION_ID) method, path, _, body = _sent(transport) - assert (method, path) == ("POST", "/v2/files/integrations/test") + assert (method, path) == ("POST", "/v3/files/integrations/test") assert body["integrationId"] == INTEGRATION_ID @@ -152,21 +152,21 @@ def test_list_files() -> None: client, transport = make_client() client.api.files.list_files(INTEGRATION_ID, path="invoices/") method, path, _, _ = _sent(transport) - assert (method, path) == ("GET", f"/v2/files/{INTEGRATION_ID}") + assert (method, path) == ("GET", f"/v3/files/{INTEGRATION_ID}") def test_get_file_info() -> None: client, transport = make_client() client.api.files.get_file_info(INTEGRATION_ID, path="invoices/invoice.pdf") method, path, _, _ = _sent(transport) - assert (method, path) == ("GET", f"/v2/files/{INTEGRATION_ID}/info") + assert (method, path) == ("GET", f"/v3/files/{INTEGRATION_ID}/info") def test_api_get_file_by_id() -> None: client, transport = make_client() client.api.files.get_file_by_id(INTEGRATION_ID, "nbfl_7hK2abc") method, path, query, _ = _sent(transport) - assert (method, path) == ("GET", f"/v2/files/{INTEGRATION_ID}/by-id/nbfl_7hK2abc") + assert (method, path) == ("GET", f"/v3/files/{INTEGRATION_ID}/by-id/nbfl_7hK2abc") assert query == "" @@ -174,7 +174,7 @@ def test_get_signed_url() -> None: client, transport = make_client() client.api.files.get_signed_url(INTEGRATION_ID, path="invoices/invoice.pdf") method, path, _, _ = _sent(transport) - assert (method, path) == ("GET", f"/v2/files/{INTEGRATION_ID}/sign") + assert (method, path) == ("GET", f"/v3/files/{INTEGRATION_ID}/sign") def test_request_upload_url() -> None: @@ -183,7 +183,7 @@ def test_request_upload_url() -> None: INTEGRATION_ID, path="invoices/invoice.pdf", contentType="application/pdf" ) method, path, _, body = _sent(transport) - assert (method, path) == ("POST", f"/v2/files/{INTEGRATION_ID}/upload-url") + assert (method, path) == ("POST", f"/v3/files/{INTEGRATION_ID}/upload-url") assert body["contentType"] == "application/pdf" @@ -193,7 +193,7 @@ def test_commit_upload() -> None: INTEGRATION_ID, path="invoices/invoice.pdf", contentType="application/pdf", sizeBytes=1024 ) method, path, _, body = _sent(transport) - assert (method, path) == ("POST", f"/v2/files/{INTEGRATION_ID}/commit") + assert (method, path) == ("POST", f"/v3/files/{INTEGRATION_ID}/commit") assert body["path"] == "invoices/invoice.pdf" @@ -201,14 +201,14 @@ def test_download_file() -> None: client, transport = make_client() client.api.files.download_file_api(INTEGRATION_ID, path="invoices/invoice.pdf") method, path, _, _ = _sent(transport) - assert (method, path) == ("GET", f"/v2/files/{INTEGRATION_ID}/download") + assert (method, path) == ("GET", f"/v3/files/{INTEGRATION_ID}/download") def test_delete_file() -> None: client, transport = make_client() client.api.files.delete_file_api(INTEGRATION_ID, path="invoices/invoice.pdf") method, path, _, _ = _sent(transport) - assert (method, path) == ("DELETE", f"/v2/files/{INTEGRATION_ID}") + assert (method, path) == ("DELETE", f"/v3/files/{INTEGRATION_ID}") def test_delete_many_files() -> None: @@ -217,7 +217,7 @@ def test_delete_many_files() -> None: INTEGRATION_ID, paths=["invoices/a.pdf", "invoices/b.pdf"] ) method, path, _, _ = _sent(transport) - assert (method, path) == ("DELETE", f"/v2/files/{INTEGRATION_ID}/bulk") + assert (method, path) == ("DELETE", f"/v3/files/{INTEGRATION_ID}/bulk") # --- public API: testing an integration (slice API-TEST, #39) ---------------- @@ -275,7 +275,7 @@ def test_api_test_files_integration_route() -> None: client, transport = make_client() client.api.files.test_files_integration(INTEGRATION_ID) method, path, _, body = _sent(transport) - assert (method, path) == ("POST", f"/v2/files/{INTEGRATION_ID}/test") + assert (method, path) == ("POST", f"/v3/files/{INTEGRATION_ID}/test") # The id travels in the path only, not in the body as on the hub route. assert "integrationId" not in body @@ -345,6 +345,6 @@ async def run() -> Any: request = transport.last_request assert request is not None assert request["method"] == "POST" - assert urlparse(request["url"]).path == f"/v2/files/{INTEGRATION_ID}/test" + assert urlparse(request["url"]).path == f"/v3/files/{INTEGRATION_ID}/test" assert request["headers"]["x-cm-projectid"] == "test-project" assert result["items"][2]["operation"] == "GetAllFiles" diff --git a/tests/test_public_files.py b/tests/test_public_files.py index 5ebf0dc..db8df8b 100644 --- a/tests/test_public_files.py +++ b/tests/test_public_files.py @@ -39,10 +39,10 @@ def _sent(transport): @pytest.mark.parametrize( ("method_name", "expected_path"), [ - ("make_file_public", "/v2/files/item/public"), - ("make_file_private", "/v2/files/item/private"), - ("make_folder_public", "/v2/files/folder/public"), - ("make_folder_private", "/v2/files/folder/private"), + ("make_file_public", "/v3/files/item/public"), + ("make_file_private", "/v3/files/item/private"), + ("make_folder_public", "/v3/files/folder/public"), + ("make_folder_private", "/v3/files/folder/private"), ], ) def test_hub_method_hits_its_own_route(method_name: str, expected_path: str) -> None: