Skip to main content
https://img.shields.io/pypi/v/humongous.svg https://travis-ci.org/mdomke/humongous.svg?branch=master https://img.shields.io/pypi/l/humongous.svg

What is this?

This is a pytest plugin, that enables you to test your code that relies on a database connection to a MongoDB and expectes certain data to be present. It allows you to specify fixtures for database collections in JSON/BSON or YAML format. Under the hood we use the mongomock library, that you should consult for documentation on how to use MongoDB mock objects. If suitable you can also use a real MongoDb server.

Configuration

If you don’t want to put your fixtures on the top-level directory of your package you have to specify a directory where humongous looks for your data definitions.

To do so put a line like the following under the pytest section of your pytest.ini-file put a

[pytest]
humongous_basedir =
  tests/unit/fixtures

humongous would then look for files ending in .yaml or .json in that directory.

You can also choose to use a real MongoDB server for your tests. In that case you might also want to configure the hostname and/or the credentials if you don’t want to stick with the default (localhost and no credentials). Use the following configuration values in your pytest.ini to adapt the settings to your needs:

[pytest]
humongous_engine = pymongo
humongous_host = mongodb://user:passwd@server.tld
humongous_dbname = mydbname

Basic usage

After you configured humongous so that it can find your fixtures you’re ready to specify some data. Regardless of the markup language you choose, the data is provided as a list of documents (dicts). The collection that these documents are being inserted into is given by the filename of your fixutre-file. E.g.: If you had a file named players.yaml with the following content:

-
  name: Mario
  surname: Götze
  position: striker

-
  name: Manuel
  surname: Neuer
  position: keeper

you’d end up with a collection players that has the above player definitions inserted. If your fixture file is in JSON/BSON format you can also use BSON specific types like $oid, $date, etc.

You get ahold of the database in you test-function by using the humongous fixture like so:

def test_players(humongous):
    assert "players" in humongous.collection_names()
    manuel = humongous.players.find_one({"name": "Manuel"})
    assert manuel["surname"] == "Neuer"

For further information refer to the mongomock documentation.

Metadata

Release files for humongous 1.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for humongous 1.3.0
File Interpreter ABI Platform Actions
humongous-1.3.0-py2.py3-none-any.whl Python 2, Python 3 none any Details for humongous-1.3.0-py2.py3-none-any.whl

Release files / humongous-1.3.0-py2.py3-none-any.whl

Download URL humongous-1.3.0-py2.py3-none-any.whl
Size 6.6 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
7c1b3fc6dbfe7d10a21d9cb1f55f0f1e2d40d30370ac4c024c64cd4bf31fb127
BLAKE2b-256 checksum
How to use checksums
ee7c0f5abc7027b3a02a0358baccfb7b0b59cf5602a9c5d15a9be296e11c93a0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for humongous 1.3.0

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page