Not Logged In

mongobox 0.1.3

Mongo Box helps starting and stopping sandboxed MongoDB instancefrom within a Python process. MongoDB instance is created with atemporary directory to store database file and is configured tobe as lightweight as possible. It will choose a free port on localhost, so it will not interfere with default MongoDB processes. It is primarily expected to be used in unit tests and for prototyping concepts.

A typical use of a Mongo Box:

```pythonfrom mongobox import MongoBox

box = MongoBox()box.start()

client = box.client() # pymongo client assert client.alive()

# do stuff with Mongo

box.stop()assert not client.alive()```

Nose----

Mongo Box comes with a Nose plugin which is automatically installed.If used as a plugin, port of the running instance will be exportedin environment variable `MONGOBOX_PORT`. This name can be overriddenin settings.

The plugin exposes several configuration options. To see them, run:

nosetests --help

The options you are interested in start with `--mongobox-`.

Unit tests----------

For an easy unit tests integration there is a `MongoTestCase` classinherited from `unittest.TestCase`. It assumes tests are run from `nosetests`with `--with-mongobox` flag. `MongoTestCases` provides a `pymongo` clientconnected to the sandboxed mongo instance and a `purge_database` helperto clean up the database after every test:

Copyright 2013 Roman Kalyakin
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.