Skip to main content

pytest-exasol-backend Plugin

The pytest-exasol-backend plugin is a collection of pytest fixtures commonly used for testing projects related to Exasol. In particular, it provides unified access to both Exasol On-Prem and SaaS backends. This eliminates the need to build different sets of tests for different backends.

Features

  • Provides session level fixtures that can be turned into connection factories for the database and the BucketFS.
  • Automatically makes the tests running on the selected backends.
  • Allows selecting either or both backends from the CLI that executes the pytest.
  • Starts the selected backends preemptively and in parallel.

Installation

The pytest-exasol-backend plugin can be installed using pip:

pip install pytest-exasol-backend

Usage in Tests

Below is an example of a test that requires access to the database. Note, that by default this test will run twice - once for each backend.

import pyexasol

def test_number_of_rows_in_my_table(backend_aware_database_params):
    with pyexasol.connect(**backend_aware_database_params, schema='MY_SCHEMA') as conn:
        num_of_rows = conn.execute('SELECT COUNT(*) FROM MY_TABLE;').fetchval()
        assert num_of_rows == 5

Here is an example of a test that requires access to the BucketFS. Again, this test will run for each backend, unless one of them is disabled in the CLI.

import exasol.bucketfs as bfs

def test_my_file_exists(backend_aware_bucketfs_params):
    my_bfs_dir = bfs.path.build_path(**backend_aware_bucketfs_params, path='MY_BFS_PATH')
    my_bfs_file = my_bfs_dir / 'my_file.dat'
    assert my_bfs_file.exists()

Sometimes it may be necessary to know which backend the test is running with. In such a case the backend fixture can be used, as in the example below.

def test_something_backend_sensitive(backend):
    if backend == 'onprem':
        # Do something special for the On-Prem database.
        pass
    elif backend == 'saas':
        # Do something special for the SaaS database.
        pass
    else:
        raise RuntimeError(f'Unknown backend {backend}')

Selecting Backends in CLI

By default, none of the backends is selected for testing. Please use the --backend option to specify the target backend. The command below runs the tests on an on-prem database.

pytest --backend=onprem my_test_suite.py

This following command runs the test on two backends.

pytest --backend=onprem --backend=saas my_test_suite.py

The next command runs the test on all backends, which currently is equivalent to the previous command since there are only two backends available.

pytest --backend=all my_test_suite.py

Please note that all selected backends starts preemptively, regardless of their actual usage in tests. Therefore, it is important to make sure the backends are not selected where they are not needed, for instance when running unit tests only.

Setting ITDE parameters in CLI

Sometimes the default ITDE parameters cannot satisfy the test requirements. The plugin allows setting some of the parameters of the api.spawn_test_environment(...) function. The parameter values can be provided in the CLI options. Currently, it is possible to set values of the following parameters:

  • --itde-db-mem-size
  • --itde-db-disk-size
  • --itde-nameserver
  • --itde-db-version

In the example below the tests are run using an instance of the DockerDB with increased memory.

pytest --backend=onprem --itde-db-mem-size "8 GiB" my_test_suite.py

These options are ignored if the "onprem" backend is not selected.

Metadata

Release files for pytest-exasol-backend 0.3.2

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

Source distribution (sdist)

Source distribution for pytest-exasol-backend 0.3.2
File Size Uploaded Provenance Actions
pytest_exasol_backend-0.3.2.tar.gz 11.3 kB Without provenance Details for pytest_exasol_backend-0.3.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pytest-exasol-backend 0.3.2
File Interpreter ABI Platform Actions
pytest_exasol_backend-0.3.2-py3-none-any.whl Python 3 none any Details for pytest_exasol_backend-0.3.2-py3-none-any.whl

Total release size: 23.5 kB

Release files / pytest_exasol_backend-0.3.2.tar.gz

Download URL pytest_exasol_backend-0.3.2.tar.gz
Size 11.3 kB
Tags Source
SHA-256 checksum
How to use checksums
249ebb48470109abda111ee126a6158a160dc17c2df7d3634af79759c0aeddee
BLAKE2b-256 checksum
How to use checksums
ca6605932504b9f9c08c0f03b4c7e71814859c5b258e48e428715679ab3e0d19
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.7.1 CPython/3.10.15 Linux/5.15.0-1074-azure

Release files / pytest_exasol_backend-0.3.2-py3-none-any.whl

Download URL pytest_exasol_backend-0.3.2-py3-none-any.whl
Size 12.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e20fc57e76533c597870d9244b619b7a13f9d528f730a75cf40ea330f0fa76ee
BLAKE2b-256 checksum
How to use checksums
523b507763d554d79ea13cc30ad1b480b10c57e437211c183d599299f156fa1d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.7.1 CPython/3.10.15 Linux/5.15.0-1074-azure

Security for pytest-exasol-backend 0.3.2

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