DEV Community

Discussion on: Unit testing PyMongo Flask applications with mongomock and patches

Collapse
 
reritom profile image
Tomas Sheers • Edited

Thank you for reading it, regarding your points:
1) I actually originally wrote this using a get_db/get_mongo function. I then rewrote with this solution for reasons I can't recall, but I reached the conclusion that the approach mentioned in this guide was the better solution. It could be subjective or I could be wrong. Maybe I'll do a write up on the other approach and re-conclude why I went with this one.

EDIT: Thinking back, my reasoning might have been related to how I first approached the testing problem, so perhaps using the function could just be down to personal taste. I use the function approach in part of the code base of the larger project where I spun this guide out of. It was used for retrieving an engine, either the GeopositionalEngine or CartesianEngine, and in that case using the get_engine/get_db approach seemed like the only logical choice. In this case it could be more up to preference.

2) Thanks for noticing. The tests in the repository works, but when writing the guide, some of the snippets got misformed or became outdated.

Its hard to find proof-readers for guides like this, so appreciate your comments.