Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Brace/add missing neo4j test #3597

Merged
merged 3 commits into from
Dec 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions langchain/src/graphs/tests/neo4j_graph.int.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/* eslint-disable no-process-env */
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey there! 👋 This PR includes changes that access environment variables via process.env to initialize a Neo4jGraph instance and establish a connection to the Neo4j database within the test cases. I've flagged this for your review to ensure the handling of environment variables aligns with best practices.


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);
});
});