Skip to main content

An in-memory stub implementation of Google Cloud Datastore for use in unit tests

Project description

An In-Memory Stub for Google Cloud Datastore

This project is a pure python implementation of the Google Cloud Datastore RPC Spec. This allows projects using the python-ndb lirary to write unit tests without needing to depend on/manage the full datastore emulator.

Installing

InMemoryCloudDatatoreStub can be installed from PyPi:

$ pip install InMemoryCloudDatastoreStub

Using

The stub can be inserted into your unit tests as a pytest fixture using monkeypatch:

from unittest.mock import magicMock

import pytest
from InMemoryCloudDatastoreStub.datastore_stub import LocalDatastoreStub

@pytest.fixture()
def ndb_stub(monkeypatch):
    stub = LocalDatastoreStub()
    monkeypatch.setattr(_datastore_api, "stub", MagicMock(return_value=stub))
    return stub

Project details


Download files

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

Source Distribution

InMemoryCloudDatastoreStub-0.0.15.tar.gz (8.4 kB view hashes)

Uploaded Source

Built Distribution

InMemoryCloudDatastoreStub-0.0.15-py3-none-any.whl (12.2 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page