From 1a6efec53098aa1f32ed42e0e50786834b7f8a56 Mon Sep 17 00:00:00 2001 From: bracesproul Date: Fri, 8 Dec 2023 11:07:12 -0800 Subject: [PATCH 1/2] proper[minor]: Add back missing Neo4j int test --- .../src/graphs/tests/neo4j_graph.int.test.ts | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 langchain/src/graphs/tests/neo4j_graph.int.test.ts diff --git a/langchain/src/graphs/tests/neo4j_graph.int.test.ts b/langchain/src/graphs/tests/neo4j_graph.int.test.ts new file mode 100644 index 000000000000..2eb115e94ce5 --- /dev/null +++ b/langchain/src/graphs/tests/neo4j_graph.int.test.ts @@ -0,0 +1,56 @@ +/* eslint-disable no-process-env */ + +import { test } from "@jest/globals"; +import { Neo4jGraph } from "../neo4j_graph.js"; + +describe.skip("Neo4j Graph Tests", () => { + const url = process.env.NEO4J_URI as string; + const username = process.env.NEO4J_USERNAME as string; + const password = process.env.NEO4J_PASSWORD as string; + let graph: Neo4jGraph; + + beforeEach(async () => { + graph = await Neo4jGraph.initialize({ url, username, password }); + }); + afterEach(async () => { + await graph.close(); + }); + + test("Schema generation works correctly", async () => { + expect(url).toBeDefined(); + expect(username).toBeDefined(); + expect(password).toBeDefined(); + + // Clear the database + await graph.query("MATCH (n) DETACH DELETE n"); + + await graph.query( + "CREATE (a:Actor {name:'Bruce Willis'})" + + "-[:ACTED_IN {roles: ['Butch Coolidge']}]->(:Movie {title: 'Pulp Fiction'})" + ); + + await graph.refreshSchema(); + console.log(graph.getSchema()); + + // expect(graph.getSchema()).toMatchInlineSnapshot(` + // "Node properties are the following: + // Actor {name: STRING}, Movie {title: STRING} + // Relationship properties are the following: + // ACTED_IN {roles: LIST} + // The relationships are the following: + // (:Actor)-[:ACTED_IN]->(:Movie)" + // `); + }); + + test("Test that Neo4j database is correctly instantiated and connected", async () => { + expect(url).toBeDefined(); + expect(username).toBeDefined(); + expect(password).toBeDefined(); + + // Integers are casted to strings in the output + const expectedOutput = [{ output: { str: "test", int: "1" } }]; + const res = await graph.query('RETURN {str: "test", int: 1} AS output'); + await graph.close(); + expect(res).toEqual(expectedOutput); + }); +}); \ No newline at end of file From afd545e711b49fa99d2cd0814a7ecb5b4fa76cde Mon Sep 17 00:00:00 2001 From: bracesproul Date: Fri, 8 Dec 2023 11:08:23 -0800 Subject: [PATCH 2/2] chore: lint files --- langchain/src/graphs/tests/neo4j_graph.int.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/langchain/src/graphs/tests/neo4j_graph.int.test.ts b/langchain/src/graphs/tests/neo4j_graph.int.test.ts index 2eb115e94ce5..3b47800fc323 100644 --- a/langchain/src/graphs/tests/neo4j_graph.int.test.ts +++ b/langchain/src/graphs/tests/neo4j_graph.int.test.ts @@ -53,4 +53,4 @@ describe.skip("Neo4j Graph Tests", () => { await graph.close(); expect(res).toEqual(expectedOutput); }); -}); \ No newline at end of file +});