Skip to content

Commit

Permalink
feat: add test for sdks
Browse files Browse the repository at this point in the history
  • Loading branch information
himanshu-dixit committed Aug 17, 2024
1 parent 9d22783 commit 59ef3b3
Show file tree
Hide file tree
Showing 6 changed files with 108 additions and 9 deletions.
17 changes: 14 additions & 3 deletions js/src/frameworks/cloudflare.spec.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
import { describe, it, expect, beforeAll } from "@jest/globals";
import { CloudflareToolSet } from "./cloudflare";
import { get } from "http";
import { getTestConfig } from "../../config/getTestConfig";


describe("Apps class tests", () => {

let cloudflareToolSet: CloudflareToolSet;
beforeAll(() => {

cloudflareToolSet = new CloudflareToolSet({
apiKey: getTestConfig().COMPOSIO_API_KEY,
baseUrl: getTestConfig().BACKEND_HERMES_URL
});
});

it("empty test", () => {

it("check if tools are coming", async () => {
const tools = await cloudflareToolSet.getActions({
actions: ['GITHUB_GITHUB_API_ROOT']
});

expect(tools.length).toBe(1);
});

});
23 changes: 22 additions & 1 deletion js/src/frameworks/langchain.spec.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,35 @@
import { describe, it, expect, beforeAll } from "@jest/globals";
import { CloudflareToolSet } from "./cloudflare";
import { get } from "http";
import { getTestConfig } from "../../config/getTestConfig";
import { LangchainToolSet } from "./langchain";


describe("Apps class tests", () => {

let langchainToolSet: LangchainToolSet;
beforeAll(() => {
langchainToolSet = new LangchainToolSet({
apiKey: getTestConfig().COMPOSIO_API_KEY,
baseUrl: getTestConfig().BACKEND_HERMES_URL
});
});

it("getools",async() => {
const tools = await langchainToolSet.getTools({
apps: ['github']
});

expect(tools).toBeInstanceOf(Array);

});

it("empty test", () => {
it("check if tools are coming", async () => {
const tools = await langchainToolSet.getActions({
actions: ['GITHUB_GITHUB_API_ROOT']
});

expect(tools.length).toBe(1);
});

});
2 changes: 1 addition & 1 deletion js/src/frameworks/langchain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export class LangchainToolSet extends BaseComposioToolSet {
apiKey?: Optional<string>,
baseUrl?: Optional<string>,
entityId?: string,
workspaceConfig: WorkspaceConfig
workspaceConfig?: WorkspaceConfig
}
) {
super(
Expand Down
24 changes: 23 additions & 1 deletion js/src/frameworks/openai.spec.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,36 @@
import { describe, it, expect, beforeAll } from "@jest/globals";
import { CloudflareToolSet } from "./cloudflare";
import { get } from "http";
import { getTestConfig } from "../../config/getTestConfig";
import { LangchainToolSet } from "./langchain";
import { OpenAIToolSet } from "./openai";


describe("Apps class tests", () => {

let openAIToolset: OpenAIToolSet;
beforeAll(() => {
openAIToolset = new OpenAIToolSet({
apiKey: getTestConfig().COMPOSIO_API_KEY,
baseUrl: getTestConfig().BACKEND_HERMES_URL
});
});

it("get tools", async () => {
const tools = await openAIToolset.getTools({
apps: ['github']
});

expect(tools).toBeInstanceOf(Array);

});

it("empty test", () => {
it("check if tools are coming", async () => {
const tools = await openAIToolset.get_actions({
actions: ['GITHUB_GITHUB_API_ROOT']
});

expect(Object.keys(tools).length).toBe(1);
});

});
25 changes: 24 additions & 1 deletion js/src/frameworks/vercel.spec.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,37 @@
import { describe, it, expect, beforeAll } from "@jest/globals";
import { CloudflareToolSet } from "./cloudflare";
import { get } from "http";
import { getTestConfig } from "../../config/getTestConfig";
import { LangchainToolSet } from "./langchain";
import { OpenAIToolSet } from "./openai";
import { VercelAIToolSet } from "./vercel";


describe("Apps class tests", () => {

let vercelAIToolSet: VercelAIToolSet;
beforeAll(() => {
vercelAIToolSet = new VercelAIToolSet({
apiKey: getTestConfig().COMPOSIO_API_KEY,
baseUrl: getTestConfig().BACKEND_HERMES_URL
});
});

it("check if tools are coming", async () => {
const tools = await vercelAIToolSet.getTools({
apps: ['github']
});

expect(tools).toBeInstanceOf(Array);

});

it("empty test", () => {
it("check if tools are coming", async () => {
const tools = await vercelAIToolSet.get_actions({
actions: ['GITHUB_GITHUB_API_ROOT']
});

expect(Object.keys(tools).length).toBe(1);
});

});
26 changes: 24 additions & 2 deletions js/src/sdk/models/triggers.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { getBackendClient } from "../testUtils/getBackendClient";
import { Triggers } from "./triggers";
import { ConnectedAccounts } from "./connectedAccounts";
import { Entity } from "./Entity";

describe("Apps class tests", () => {
let backendClient;
let triggers: Triggers;
Expand Down Expand Up @@ -33,6 +34,27 @@ describe("Apps class tests", () => {
expect(triggerList[0].appName).toBe("github");
});


});


describe("Apps class tests subscribe", () => {
let backendClient;
let triggers: Triggers;
let connectedAccounts: ConnectedAccounts;
let entity: Entity;

let triggerId: string;

beforeAll(() => {
backendClient = getBackendClient();
triggers = new Triggers(backendClient);
connectedAccounts = new ConnectedAccounts(backendClient);
entity = new Entity(backendClient, "default");
});



it("should create a new trigger for gmail", async () => {
const connectedAccount = await connectedAccounts.list({ query: { user_uuid: 'default' } });

Expand Down Expand Up @@ -61,7 +83,7 @@ describe("Apps class tests", () => {
});

it("should subscribe to a trigger", async () => {
await triggers.subscribe((data) => {
await triggers.subscribe((data) => {
// Explicitly passing the data to an empty function body
}, {
appName: "gmail",
Expand All @@ -71,5 +93,5 @@ describe("Apps class tests", () => {
await triggers.unsubscribe();

});

});

0 comments on commit 59ef3b3

Please sign in to comment.