Welcome to mongomock_mate Documentation
Use mongomock_mate:
Just import mongomock_mate at begin of your script. It use monkey patch:
import mongomock_mate
Features:
Data Persistence: dump and load data
import mongomock_mate
# dump
db = client["test"]
c_user = db["user"]
c_user.insert([{"_id": 1, "name": "Alice"}, {"_id": 2, "name": "Bob"}])
db.dump_db("test.json")
# load
db = client["test"]
db.load_db("test.json")
# other params
def dump_db(self, file,
pretty=False,
overwrite=False,
verbose=True):
"""
Dump :class:`mongomock.database.Database` to a local file. Only support
``*.json`` or ``*.gz`` (compressed json file)
:param file: file path.
:param pretty: bool, toggle on jsonize into pretty format.
:param overwrite: bool, allow overwrite to existing file.
:param verbose: bool, toggle on log.
"""
def load_db(self, file, check_dbname=True, verbose=True):
"""
Load :class:`mongomock.database.Database` from a local file.
:param file: file path.
:param check_dbname: bool, if True, the dbname has to be matched.
:param verbose: bool, toggle on log.
"""
Working with mongoengine ORM:
2018-07-30:
At mongomock==3.10.0, insert operation doesn’t work with latest mongoengine==0.15.3, because the implementation of WriteConcern is not correct in mongomock.
import mongomock_mate
from mongoengine import connect, Document, fields
connect('mongoenginetest', host='mongomock://localhost')
class User(Document):
_id = fields.IntField(primary_key=True)
name = fields.StringField()
User.objects.insert(User(_id=1, name="Alice"))
Quick Links
Install
mongomock_mate is released on PyPI, so all you need is:
$ pip install mongomock_mate
To upgrade to latest version:
$ pip install --upgrade mongomock_mate
Metadata
Release files for mongomock-mate 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| mongomock_mate-0.0.1.tar.gz | 14.8 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| mongomock_mate-0.0.1-py2-none-any.whl | Python 2 | none | any | Details |
Total release size: 39.7 kB
Release files / mongomock_mate-0.0.1.tar.gz
| Download URL | mongomock_mate-0.0.1.tar.gz |
|---|---|
| Size | 14.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0b55f54f2fa131290ac4251d05306a2599c6829d23682706ed93aba4d9597b0a
|
|
BLAKE2b-256 checksum How to use checksums |
2ffbcd39929a176990af81f5d433c4b8fc403127903ce019370712ef100f47b1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/2.7.13
|
Release files / mongomock_mate-0.0.1-py2-none-any.whl
| Download URL | mongomock_mate-0.0.1-py2-none-any.whl |
|---|---|
| Size | 24.9 kB |
| Tags | Python 2 |
|
SHA-256 checksum How to use checksums |
445fc674381a5435966a3fb0fbeb6463f189ee171af384f99ff76b505e956038
|
|
BLAKE2b-256 checksum How to use checksums |
66552377f516c3d9365c6e66a19bfbf88a9b6a34f4ea06b092d11d7e3814684c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/2.7.13
|
Security for mongomock-mate 0.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.