From 9576a814c5126dd1d410a09f09a86753b5a909dc Mon Sep 17 00:00:00 2001 From: fern-api <115122769+fern-api[bot]@users.noreply.github.com> Date: Fri, 15 Mar 2024 13:40:26 +0000 Subject: [PATCH] Release 0.0.85 --- .github/workflows/tests.yml | 2 +- pyproject.toml | 2 +- src/fern/core/client_wrapper.py | 2 +- tests/__init__.py | 2 + tests/conftest.py | 16 +++++++ tests/test_snippets.py | 83 +++++++++++++++++++++++++++++++++ tests/utilities.py | 32 +++++++++++++ 7 files changed, 136 insertions(+), 3 deletions(-) create mode 100644 tests/__init__.py create mode 100644 tests/conftest.py create mode 100644 tests/test_snippets.py create mode 100644 tests/utilities.py diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 4dd36af..7db1091 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -38,4 +38,4 @@ jobs: - name: Test run: | - poetry run pytest . + fern test --command "poetry run pytest -rP ." diff --git a/pyproject.toml b/pyproject.toml index 5637ccd..708b94a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "fern-api" -version = "0.0.0-rc1" +version = "0.0.85" description = "" readme = "README.md" authors = [] diff --git a/src/fern/core/client_wrapper.py b/src/fern/core/client_wrapper.py index 6e6ad5a..b64502d 100644 --- a/src/fern/core/client_wrapper.py +++ b/src/fern/core/client_wrapper.py @@ -16,7 +16,7 @@ def get_headers(self) -> typing.Dict[str, str]: headers: typing.Dict[str, str] = { "X-Fern-Language": "Python", "X-Fern-SDK-Name": "fern-api", - "X-Fern-SDK-Version": "0.0.0-rc1", + "X-Fern-SDK-Version": "0.0.85", } headers["Authorization"] = f"Bearer {self._get_token()}" return headers diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..f3ea265 --- /dev/null +++ b/tests/__init__.py @@ -0,0 +1,2 @@ +# This file was auto-generated by Fern from our API Definition. + diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 0000000..736f31a --- /dev/null +++ b/tests/conftest.py @@ -0,0 +1,16 @@ +# This file was auto-generated by Fern from our API Definition. + +import os + +import pytest +from fern.client import AsyncFern, Fern + + +@pytest.fixture +def client() -> Fern: + return Fern(token=os.getenv("ENV_TOKEN", "token"), base_url=os.getenv("TESTS_BASE_URL", "base_url")) + + +@pytest.fixture +def async_client() -> AsyncFern: + return AsyncFern(token=os.getenv("ENV_TOKEN", "token"), base_url=os.getenv("TESTS_BASE_URL", "base_url")) diff --git a/tests/test_snippets.py b/tests/test_snippets.py new file mode 100644 index 0000000..9d11c8a --- /dev/null +++ b/tests/test_snippets.py @@ -0,0 +1,83 @@ +# This file was auto-generated by Fern from our API Definition. + +from fern.client import AsyncFern, Fern + +from fern import EndpointIdentifier, EndpointMethod, Sdk_Python + +from .utilities import validate_response + + +async def test_get(client: Fern, async_client: AsyncFern) -> None: + expected_response = [ + { + "type": "python", + "sdk": {"package": "vellum-ai", "version": "1.2.1"}, + "sync_client": 'import Vellum from vellum.client\n\nclient = Vellum(api_key="YOUR_API_KEY")\nclient.search(query="Find documents written in the last 5 days")\n', + "async_client": 'import VellumAsync from vellum.client\n\nclient = VellumAsync(api_key="YOUR_API_KEY")\nawait client.search(query="Find documents written in the last 5 days")\n', + }, + { + "type": "typescript", + "sdk": {"package": "vellum-ai", "version": "1.2.1"}, + "client": 'import { VellumClient } from "vellum-ai";\n\nconst vellum = VellumClient({\n apiKey="YOUR_API_KEY"\n})\nvellum.search({\n query: "Find documents written in the last 5 days"\n})\n', + }, + ] + response = client.snippets.get(endpoint=EndpointIdentifier(method=EndpointMethod.GET, path="/v1/search")) + validate_response(response, expected_response) + + async_response = await async_client.snippets.get( + endpoint=EndpointIdentifier(method=EndpointMethod.GET, path="/v1/search") + ) + validate_response(async_response, expected_response) + + +async def test_load(client: Fern, async_client: AsyncFern) -> None: + expected_response = { + "next": 2, + "snippets": { + "/v1/search": { + "GET": [ + { + "type": "python", + "sdk": {"package": "vellum-ai", "version": "1.2.1"}, + "sync_client": 'import Vellum from vellum.client\n\nclient = Vellum(api_key="YOUR_API_KEY")\nclient.search(query="Find documents written in the last 5 days")\n', + "async_client": 'import Vellum from vellum.client\n\nclient = Vellum(api_key="YOUR_API_KEY")\nclient.search(query="Find documents written in the last 5 days")\n', + }, + { + "type": "typescript", + "sdk": {"package": "vellum-ai", "version": "1.2.1"}, + "client": 'import { VellumClient } from "vellum-ai";\n\nconst vellum = VellumClient({\n apiKey="YOUR_API_KEY"\n})\nvellum.search({\n query: "Find documents written in the last 5 days"\n})\n', + }, + ] + }, + "v1/document-indexes": { + "POST": [ + { + "type": "python", + "sdk": {"package": "vellum-ai", "version": "1.2.1"}, + "sync_client": 'import Vellum from vellum.client\n\nclient = Vellum(api_key="YOUR_API_KEY")\nclient.document_indexes.create(name="meeting-reports", status="ACTIVE")\n', + "async_client": 'import VellumAsync from vellum.client\n\nclient = VellumAsync(api_key="YOUR_API_KEY")\nawait client.document_indexes.create(name="meeting-reports", status="ACTIVE")\n', + }, + { + "type": "typescript", + "sdk": {"package": "vellum-ai", "version": "1.2.1"}, + "client": 'import { VellumClient } from "vellum-ai";\n\nconst vellum = VellumClient({\n apiKey="YOUR_API_KEY"\n})\nvellum.documentIndexes.create({\n name: "meeting-reports",\n status: "ACTIVE"\n})\n', + }, + ] + }, + }, + } + response = client.snippets.load( + page=1, + org_id="vellum", + api_id="vellum-ai", + sdks=[Sdk_Python(type="python", package="vellum-ai", version="1.2.1")], + ) + validate_response(response, expected_response) + + async_response = await async_client.snippets.load( + page=1, + org_id="vellum", + api_id="vellum-ai", + sdks=[Sdk_Python(type="python", package="vellum-ai", version="1.2.1")], + ) + validate_response(async_response, expected_response) diff --git a/tests/utilities.py b/tests/utilities.py new file mode 100644 index 0000000..e59d044 --- /dev/null +++ b/tests/utilities.py @@ -0,0 +1,32 @@ +# This file was auto-generated by Fern from our API Definition. + +import json +import typing + +try: + import pydantic.v1 as pydantic # type: ignore +except ImportError: + import pydantic # type: ignore + + +def validate_response(response: typing.Any, json_expectation: typing.Any) -> None: + if not isinstance(response, dict) and not issubclass(type(response), pydantic.BaseModel): + assert response == json_expectation, "Primitives found, expected: {0}, Actual: {1}".format( + json_expectation, response + ) + return + + response_json = response + if issubclass(type(response), pydantic.BaseModel): + response_json = json.loads(response.json()) + + for key, value in json_expectation.items(): + assert key in response_json + if isinstance(value, dict): + validate_response(response_json[key], value) + else: + assert response_json[key] == value + + # Ensure there are no additional fields here either + del response_json[key] + assert len(response_json) == 0, "Additional fields found, expected None: {0}".format(response_json)