community[patch]: Handle exceptions where node props aren't consistent in neo4j schema (#22027)

This commit is contained in:
Tomaz Bratanic
2024-05-22 17:21:56 +02:00
committed by GitHub
parent b0ef5e778a
commit d8a1f1114d
2 changed files with 47 additions and 14 deletions

View File

@@ -333,3 +333,28 @@ def test_enhanced_schema() -> None:
# remove metadata portion of schema
del graph.structured_schema["metadata"]
assert graph.structured_schema == expected_output
def test_enhanced_schema_exception() -> None:
"""Test no error with weird schema."""
url = os.environ.get("NEO4J_URI")
username = os.environ.get("NEO4J_USERNAME")
password = os.environ.get("NEO4J_PASSWORD")
assert url is not None
assert username is not None
assert password is not None
graph = Neo4jGraph(
url=url, username=username, password=password, enhanced_schema=True
)
graph.query("MATCH (n) DETACH DELETE n")
graph.query("CREATE (:Node {foo:'bar'})," "(:Node {foo: 1}), (:Node {foo: [1,2]})")
graph.refresh_schema()
expected_output = {
"node_props": {"Node": [{"property": "foo", "type": "STRING"}]},
"rel_props": {},
"relationships": [],
}
# remove metadata portion of schema
del graph.structured_schema["metadata"]
assert graph.structured_schema == expected_output