# mongomock/mongomock

Small library for mocking pymongo collection objects for testing purposes

Repository: https://github.com/mongomock/mongomock
Canonical: https://ross.abutalabs.com/products/mongomock
Language: Python
License: ISC
License Family: permissive
Topics: python, mongodb, testing, mocking
Last push: 2025-06-30T22:08:28+00:00

## Health v2 (maintenance only)
Score: 43/100 (v2, computed 2026-09-03T02:20:16.233290+00:00)
- activity 29, release rhythm 28, longevity 100
- inputs: {"age_days": 5285, "days_push": 429, "days_rel": 653, "gap_med": 68, "n_releases_24m": 2}
- flags: none
- formula: round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10)

## Adoption (not part of the score)
Stars 1003, forks 359 (observed 2026-09-03T02:15:15.239959+00:00)

## What it is
Mongomock is a small Python library that provides a fake in-memory implementation of pymongo collection objects for testing MongoDB-dependent code. It lets unit tests run without a real MongoDB server while exercising the same query and update API.

## Use cases
- unit test python code that uses pymongo without a mongodb server
- run mongodb-dependent tests in CI without database setup
- replace a real mongo collection with an in-memory fake in tests
- test mongodb queries and updates deterministically
- avoid record-replay mocks when testing database code

## When to choose
- you want fast, dependency-free unit tests for pymongo-based code
- you cannot easily provision or clean a real MongoDB instance in your test environment
- your code uses simple MongoDB operations supported by the fake

## When to avoid
- you need to test against real MongoDB behavior, server features, or aggregation fidelity
- your code relies on advanced MongoDB features mongomock does not implement
- you are doing integration or end-to-end testing where a real database is available

## Facets
- artifact type: library
- maturity: maintenance
- function: mocking, testing, database-driver
- domain: testing, databases, developer-tools
- platform: python
- tags: mongodb, pymongo, test-doubles, unit-testing

## Member repositories
- mongomock/mongomock (main) score 43

## Provenance
- Observed fields: from GitHub, fetched 2026-09-03T02:15:15.239959+00:00.
- Health v2: computed from the inputs above; adoption is never an input.
- Inferred fields (summary, facets, guidance): AI-extracted, prompt v1, taxonomy v1, on 2026-08-30T07:13:54.201796+00:00, confidence not recorded.
  - readme: https://github.com/mongomock/mongomock (fetched 2026-09-03T02:15:15.239959+00:00, sha 50645de3035f)
  - registry_pypi: https://pypi.org/pypi/mongomock/json (fetched 2026-08-29T13:13:45.118589+00:00, sha 2e59e8655f12)
- Data as of 2026-08-30T08:39:29.467469+00:00.
