-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a45968e
commit 8157994
Showing
7 changed files
with
136 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,4 +38,4 @@ jobs: | |
|
||
- name: Test | ||
run: | | ||
poetry run pytest . | ||
fern test --command "poetry run pytest -rP ." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |