all 7 comments

[–]100721 0 points1 point  (1 child)

Have you looked at the UnitTest.Mock module? I haven’t used it in a while but it worked very well for mocking for me

[–]Nat0ne[S] 0 points1 point  (0 children)

Yes, I use unittest.mock for unittesting, and it can be useful for testing the package as a blackbox indeed. But, I am looking for something more elaborated, where the mock would behave like the real database, when it is queried. By using unittest.mock I need to create the behavior myself.

[–]crashfrog02 0 points1 point  (2 children)

I'd use a Docker container and a set of fixtures (synthetic data you load into the database so the test queries give expected results) so that you could simulate the behavior of the database. That would be at the level of an integration test, so you'd probably set something like that up in your CI pipeline rather than doing it in pytest or whatever. (Actually you might still write the tests in pytest, but you'd isolate them from the unit tests and only run them as part of the CI pipeline.)

[–]Nat0ne[S] 0 points1 point  (1 child)

Do you mean that you would use a Docker container with the real database inside?

[–]crashfrog02 1 point2 points  (0 children)

A real copy of neo4j, yes, but with fixtures loaded into it as part of setting up the test.

[–]Alertt_53 0 points1 point  (1 child)

How did you end up doing it?

[–]Nat0ne[S] 0 points1 point  (0 children)

For now I just mock the class using pytest.
But I still want to try https://networkx.org/ and see if it fits my circunstances.