Skip to main content

A Python library to ease testing applications that rely on MongoDB as a datastore

Project description

MongoDB Test Util

This library provides a handful of useful functionality for easing the testing
of systems that rely on *MongoDB* as a datastore

Start and Teardown mongod

For most use cases, you can use this snippet to startup a ``mongod`` instance
for your test environment::

from mongo_test.handlers import startup_handle

To tear an instance down if one exists::

from mongo_test.handlers import teardown_handle


*MongoTest* allows you to specify fixtures in *yaml*, with a few conveniences.
A sample yaml file would look something like::

collection: users
drop: true
_id: !oid 1
username: idbentley
first_name: Ian
last_name: Bentley

``!oid`` is a custom *yaml* constructor provided by *MongoTest*. This constructor
allows you to create object ids based on an integer seed. You can access the
constructor directly from python, which allows you to write assertions on
document identity::

from mongo_test.fixtures import oid_con
user = db.coll.find({name: ''})
assert user['_id'] = oid_con(1)

A complete example

See the tests for a complete simple example.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for MongoTest, version 0.1.2
Filename, size File type Python version Upload date Hashes
Filename, size MongoTest-0.1.2.tar.gz (3.7 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page