{"id":22295374,"url":"https://github.com/alkc/flask-mongomock-example","last_synced_at":"2026-04-10T16:34:19.691Z","repository":{"id":168941279,"uuid":"644751773","full_name":"alkc/flask-mongomock-example","owner":"alkc","description":"Example of using mongomock for testing in a global mongo db class in a flask app","archived":false,"fork":false,"pushed_at":"2023-05-24T13:19:02.000Z","size":17,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-25T22:32:13.722Z","etag":null,"topics":["flask","mongodb","mongomock","pytest","pytest-mock","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alkc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-05-24T07:23:25.000Z","updated_at":"2023-05-24T10:27:55.000Z","dependencies_parsed_at":"2023-05-28T23:00:36.104Z","dependency_job_id":null,"html_url":"https://github.com/alkc/flask-mongomock-example","commit_stats":null,"previous_names":["alkc/flask-mongomock-issues","alkc/flask-mongomock-example"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/alkc/flask-mongomock-example","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alkc%2Fflask-mongomock-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alkc%2Fflask-mongomock-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alkc%2Fflask-mongomock-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alkc%2Fflask-mongomock-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alkc","download_url":"https://codeload.github.com/alkc/flask-mongomock-example/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alkc%2Fflask-mongomock-example/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265237703,"owners_count":23732514,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["flask","mongodb","mongomock","pytest","pytest-mock","python"],"created_at":"2024-12-03T17:41:53.872Z","updated_at":"2026-04-10T16:34:19.660Z","avatar_url":"https://github.com/alkc.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Testing a pymongo/Flask app using pytest and mongomock\n\nThis repo contains an example on how to use mongomock to replace a `pymongo.MongoClient` inside a Flask app.\n\nThe dependencies, test cases, and structure of the app are based on a real project where I was scratching my head over this exact problem.\n\nThe setup of the `db.MongoDB` class imported and initialized in app.py is based on the MongoAdapter in [Clinical-Genomics/scout](https://github.com/Clinical-Genomics/scout/blob/main/scout/adapter/mongo/base.py)\n\nTo try it out, clone this repo, install the dependencies in `requirements.txt` and run pytest:\n\n``` python\ngit clone https://github.com/alkc/flask-mongomock-example.git\ncd flask-mongomock-example\npip install --requirement requirements.txt\npytest .\n```\n\nI'm open for feedback if you think there is a smarter/better way of doing this.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falkc%2Fflask-mongomock-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falkc%2Fflask-mongomock-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falkc%2Fflask-mongomock-example/lists"}