Skip to content

Commit

Permalink
add test to retrieve by example id
Browse files Browse the repository at this point in the history
  • Loading branch information
dsinghvi committed May 23, 2024
1 parent 4c8b440 commit 1e7fe59
Showing 1 changed file with 47 additions and 7 deletions.
54 changes: 47 additions & 7 deletions packages/fdr-sdk/src/__test__/SdkSnippetHolder.test.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { SDKSnippetHolder } from "../converters";

describe("SDK Snippet Holder", () => {
it("Test SDK Snippet Retrieval", () => {
it("Retrieve by Endpoint ID", () => {
const sdkSnippetHolder = new SDKSnippetHolder({
snippetsBySdkIdAndEndpointId: {
"python|acme|0.0.1": {
"endpoint_connectors.list": [
{
async_client: "client = AsyncAcme(api_key='YOUR_API_KEY')",
async_client: "client = AsyncAcme0(api_key='YOUR_API_KEY')",
sdk: { package: "acme", version: "0.0.1" },
sync_client: "client = Acme(api_key='YOUR_API_KEY')",
sync_client: "client = Acme0(api_key='YOUR_API_KEY')",
type: "python",
},
],
Expand All @@ -22,9 +22,9 @@ describe("SDK Snippet Holder", () => {
DELETE: [],
GET: [
{
async_client: "client = AsyncAcme(api_key='YOUR_API_KEY')",
async_client: "client = AsyncAcme1(api_key='YOUR_API_KEY')",
sdk: { package: "acme", version: "0.0.1" },
sync_client: "client = Acme(api_key='YOUR_API_KEY')",
sync_client: "client = Acme1(api_key='YOUR_API_KEY')",
type: "python",
},
],
Expand All @@ -48,7 +48,47 @@ describe("SDK Snippet Holder", () => {
endpointId: "endpoint_connectors.list",
exampleId: undefined,
});
console.log(snippet);
expect(snippet?.async_client).toEqual("client = AsyncAcme(api_key='YOUR_API_KEY')");
expect(snippet?.async_client).toEqual("client = AsyncAcme0(api_key='YOUR_API_KEY')");
});

it("Retrieve by Example ID", () => {
const sdkSnippetHolder = new SDKSnippetHolder({
snippetsBySdkIdAndEndpointId: {
"python|acme|0.0.1": {
"endpoint_connectors.list": [
{
async_client: "client = AsyncAcme1(api_key='YOUR_API_KEY')",
sdk: { package: "acme", version: "0.0.1" },
sync_client: "client = Acme1(api_key='YOUR_API_KEY')",
type: "python",
exampleIdentifier: "example1",
},
{
async_client: "client = AsyncAcme2(api_key='YOUR_API_KEY')",
sdk: { package: "acme", version: "0.0.1" },
sync_client: "client = Acme2(api_key='YOUR_API_KEY')",
type: "python",
exampleIdentifier: "example2",
},
],
},
},
snippetTemplatesByEndpointId: {},
snippetsBySdkId: {},
snippetsConfigWithSdkId: {
pythonSdk: {
package: "acme",
sdkId: "python|acme|0.0.1",
},
},
snippetTemplatesByEndpoint: {},
});
const snippet = sdkSnippetHolder.getPythonCodeSnippetForEndpoint({
endpointMethod: "GET",
endpointPath: "/users/v1",
endpointId: "endpoint_connectors.list",
exampleId: "example2",
});
expect(snippet?.async_client).toEqual("client = AsyncAcme2(api_key='YOUR_API_KEY')");
});
});

0 comments on commit 1e7fe59

Please sign in to comment.