Is there a library to unit test graphdb cypher queries using python


I have some CYPHER queries that are executed using neo4j-driver. Things works fine in real, but I want to also write unit tests for this class so all possible scenarios are verified. With mysql etc we can use use sqllite and let the queries run on it. Is there a lite version of neo4j db that we can spawn up for test and kill after use?
I don't want to mock all db and session objs, as those tests are pretty dummy and not really useful in case things change.


Do you want to test that they work as expected (i.e. return the proper items) or just that they execute? If the latter, I would say a docker container running neo4j with a small seed script would do the trick as it spins up relatively quickly, is lightweight, and will let you test that the responses are as expected.

yea the later "just that they execute" as the queries will almost be hardcoded with parameter that change. so they would be verified.

Yeah, a simple docker container would be the easiest way to go then - you wouldn't even need to seed the DB, just check that there is not an exception.

With python, this can be as simple as using a try...catch and failing the test on any exception.

    print(f"{QUERY} failed")

You can also put your queries into .cypher files and use a linter like libcypher-parser to check that your queries are valid.