worlddriven icon indicating copy to clipboard operation
worlddriven copied to clipboard

Mock mongodb backend in the test

Open TooAngel opened this issue 5 years ago • 2 comments

Currently, the python tests are trying to connect to the MongoDB backend. AFAIK the tests don't use the backend and they shouldn't. For faster and easier running of the tests, the MongoDB backend needs to be completely mocked.

TooAngel avatar Oct 03 '20 09:10 TooAngel

Hi @TooAngel I'm kinda curious about this one. I'm trying to understand which tests should be mocked. I looked here but it looks like the tests are already covered by those patch decorators.

Please help me understand, which tests should be mocked/altered?

benji011 avatar Oct 03 '20 09:10 benji011

Cool. I didn't look too much into it yet. I usually have a MongoDB server running on my machine. Yesterday I stopped it for reasons and recognized that the tests got stuck on the tests/test_frontend.py test already.

I would guess the issue lies in the fact that the mongo connection is already initiated in src/server.py, maybe we can mock this before the server.py is loaded.

Easiest to test, checkout the repository, run the tests without a MongoDB server listening on localhost:27017 and you should see the issue.

Does that help?

TooAngel avatar Oct 03 '20 09:10 TooAngel