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.
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.
for QUERY in QUERIES:
try:
GRAPH.run(QUERY)
except:
print(f"{QUERY} failed")