Skip to main content

RavenDB Test Driver

ravendb-test-driver runs your integration tests against a real RavenDB server instead of a mock. Each test gets its own isolated database, created on demand and torn down afterwards, so tests do not leak state into one another. You write ordinary ravendb client code; the driver handles the server and the per-test database lifecycle.

Install

pip install ravendb-test-driver

Python 3.10+ is required.

Providing a server: pick one

The driver needs a RavenDB server to talk to. Choose how it should get one based on your environment.

1. Embedded server (default, needs .NET)

Out of the box the driver boots an embedded RavenDB server (via ravendb-embedded). Nothing to configure, but the embedded server is a .NET application, so a matching runtime must be installed:

ravendb-test-driver version Required runtime
7.2.x .NET 10
7.1.x .NET 8

Check with dotnet --list-runtimes. The requirement tracks the embedded server and can change on a minor upgrade, so re-check it when you bump versions.

2. Self-contained embedded server (no system .NET)

Let the driver download and cache a self-contained RavenDB build. It manages the server for you without calling dotnet:

from ravendb_embedded import ServerOptions
from ravendb_test_driver import RavenTestDriver

options = ServerOptions()
options.with_auto_downloaded_server()
RavenTestDriver.configure_server(options)

The embedded package detects the host operating system and architecture, so the same test configuration is portable across supported Windows, Linux, and macOS machines.

Call configure_server() before the first get_document_store(). The first run downloads 100 MB+; later runs reuse the cache. Self-contained mode needs no system .NET, but normal RavenDB OS dependencies still apply; minimal Linux images may need their distribution's ICU package. See labs/04-embedded-no-dotnet.md.

3. Attach to a server you run yourself (no .NET)

If you would rather not put .NET on the test machine (containerized CI, locked-down hosts), run RavenDB yourself (Docker, testcontainers, a shared CI service) and point the driver at its URL. The driver skips the embedded boot entirely and still creates an isolated database per test.

from ravendb_test_driver import RavenTestDriver

RavenTestDriver.configure_external_server("http://localhost:8080")
# or set RAVENDB_TEST_SERVER_URL in the environment

For HTTPS with client-certificate authentication:

RavenTestDriver.configure_external_server(
    "https://my-ravendb",
    certificate_pem_path="client.pem",
    trust_store_path="ca.crt",  # needed when the server CA is not already trusted
)

The equivalent environment variables are RAVENDB_TEST_SERVER_URL, RAVENDB_TEST_SERVER_CERT, and RAVENDB_TEST_SERVER_CA. Call the configuration method once, before the first get_document_store(). A runnable Docker / testcontainers guide is in labs/01-attach-to-server.md.

Usage

Subclass RavenTestDriver (or hold an instance) and call get_document_store() in each test to get a store backed by a fresh database:

from unittest import TestCase
from ravendb_test_driver import RavenTestDriver


class TestBasic(TestCase):
    def setUp(self):
        self.test_driver = RavenTestDriver()

    def test_stores_a_document(self):
        with self.test_driver.get_document_store() as store:   # isolated database
            with store.open_session() as session:
                session.store({"Name": "John"}, "people/1")
                session.save_changes()

Runnable example: labs/02-embedded-per-test.md.

Seeding data and waiting for indexes

  • Override setup_database(self, store) to seed or configure every database the driver hands out (indexes, reference data, and so on).
  • get_document_store(options) accepts GetDocumentStoreOptions; set a wait_for_indexing_timeout to block until indexing settles, or call wait_for_indexing(store) yourself.
  • wait_for_user_to_continue_the_test(store) opens RavenDB Studio so you can inspect the data mid-test.

Runnable example: labs/03-seeding-indexes.md.

Links

The runnable lab scripts live in this repository and are not installed into site-packages.

Download files

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

Source Distribution

ravendb_test_driver-7.2.5.post1.tar.gz (14.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ravendb_test_driver-7.2.5.post1-py3-none-any.whl (13.2 kB view details)

Uploaded Python 3

File details

Details for the file ravendb_test_driver-7.2.5.post1.tar.gz.

File metadata

File hashes

Hashes for ravendb_test_driver-7.2.5.post1.tar.gz
Algorithm Hash digest
SHA256 950fd2f6b8ed08de89573b29b9d12e1c8d5a6f08acc00e2f4990cf477043c145
MD5 fb49332973aa05f60d04295b53e6e577
BLAKE2b-256 2016fa59b8b3120c8dd9b825913e16484607f996892e36e7dcf77225ca191126

See more details on using hashes here.

File details

Details for the file ravendb_test_driver-7.2.5.post1-py3-none-any.whl.

File metadata

File hashes

Hashes for ravendb_test_driver-7.2.5.post1-py3-none-any.whl
Algorithm Hash digest
SHA256 46a7e01137691358f78af60e7a11c67ca6c849f11a3b5cc26103f1e8fa10a187
MD5 ce3761b7d958bb2a2215068142c3091f
BLAKE2b-256 305160b28862546254ba3a749a4f6b3baf8bebeaf90a794cb7a204da9d65cc25

See more details on using hashes here.

Release history Release notifications | RSS feed

7.2.5.post2

2 files

This release

7.2.5.post1 This release

2 files

7.2.5

2 files

7.2.3

2 files

7.2.2

2 files

7.2.1

2 files

7.2.0

2 files

7.1.5

2 files

7.1.4

2 files

7.1.3

2 files

7.1.2.post1

2 files

7.1.2

2 files

7.0.2

2 files

7.0.0

2 files

6.2.4

2 files

6.0.0.post6

2 files

6.0.0.post5

2 files

6.0.0.post4

2 files

6.0.0.post3

2 files

6.0.0.post2

2 files

6.0.0.post1

2 files

6.0

3 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page