Skip to content

Commit

Permalink
Release 0.0.83
Browse files Browse the repository at this point in the history
  • Loading branch information
fern-api[bot] committed Mar 15, 2024
1 parent a45968e commit 8157994
Show file tree
Hide file tree
Showing 7 changed files with 136 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ jobs:

- name: Test
run: |
poetry run pytest .
fern test --command "poetry run pytest -rP ."
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "fern-api"
version = "0.0.7"
version = "0.0.83"
description = ""
readme = "README.md"
authors = []
Expand Down
2 changes: 1 addition & 1 deletion src/fern/core/client_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.7",
"X-Fern-SDK-Version": "0.0.83",
}
headers["Authorization"] = f"Bearer {self._get_token()}"
return headers
Expand Down
2 changes: 2 additions & 0 deletions tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# This file was auto-generated by Fern from our API Definition.

16 changes: 16 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -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"))
83 changes: 83 additions & 0 deletions tests/test_snippets.py
Original file line number Diff line number Diff line change
@@ -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)
32 changes: 32 additions & 0 deletions tests/utilities.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 8157994

Please sign in to comment.