Skip to main content

pytest-exasol-extension Plugin

The pytest-exasol-extension plugin provides pytest fixtures for preparing a database for the extension tests. The fixtures are backend agnostic. They run for the selected backends (see the documentation for the pytest-exasol-backend plugin).

Installation

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

pip install pytest-exasol-extension

Usage in Tests

Below is an example of a test that requires a database connection with an open test schema.

import pytest

@pytest.fixture(scope="session")
def db_schema_name() -> str:
    """Let's override a randomly generated db schema for the test, giving it a meaningful name."""
    return 'MY_TEST_SCHEMA'

def test_something(pyexasol_connection):
    ...

Next, is an example of a test that needs to store a bucket-fs connection object in the database.

def test_something_else(bucketfs_connection_factory):
    bucketfs_connection_factory('my_connection_name,' 'some_path/in_the_bucket')
    ...

The following fixtures are used to test various deployment scenarios where the connection parameters for the Database and the BucketFS are supplied in a command line. The first two fixtures provide dictionaries of standard cli parameters (StdParams) defined in the exasol-python-extension-common.

`database_std_params` - the Database connection parameters.
`bucketfs_std_params` - the BucketFs connection parameters.

The next two fixtures - database_cli_args and bucketfs_cli_args - give the same parameters as the previous two but in the form of command line arguments. They are helpful for testing the CLI directly, for example using the click.CliRunner as in the samples below. There is also a fixture - cli_args - that combines these two argument strings.

import click
from click.testing import CliRunner
from exasol.python_extension_common.cli.std_options import (StdParams, StdTags, select_std_options)
from exasol.pytest_backend import (BACKEND_ONPREM, BACKEND_SAAS)

def test_db_connection_cli(backend, database_cli_args):
    if backend == BACKEND_ONPREM:
        tags = StdTags.DB | StdTags.ONPREM
    elif backend == BACKEND_SAAS:
        tags = StdTags.DB | StdTags.SAAS
    else:
        ValueError(f'Unknown backend {backend}')

    def test_something_with_db(**kwargs):
        pass

    opts = select_std_options(tags)
    cmd = click.Command('whatever', params=opts, callback=test_something_with_db)
    runner = CliRunner()
    runner.invoke(cmd, args=database_cli_args, catch_exceptions=False, standalone_mode=False)

def test_bucketfs_connection_cli(backend, bucketfs_cli_args):
    if backend == BACKEND_ONPREM:
        tags = StdTags.BFS | StdTags.ONPREM
    elif backend == BACKEND_SAAS:
        tags = StdTags.BFS | StdTags.SAAS
    else:
        ValueError(f'Unknown backend {backend}')

    def test_something_with_bucketfs(**kwargs):
        pass

    opts = select_std_options(tags)
    cmd = click.Command('whatever', params=opts, callback=test_something_with_bucketfs)
    runner = CliRunner()
    runner.invoke(cmd, args=bucketfs_cli_args, catch_exceptions=False, standalone_mode=False)

Note, that by default the tests will run twice - once for each backend.

Metadata

Release files for pytest-exasol-extension 1.1.0

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-extension 1.1.0
File Size Uploaded Provenance
pytest_exasol_extension-1.1.0.tar.gz 4.4 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for pytest-exasol-extension 1.1.0
File Interpreter ABI Platform
pytest_exasol_extension-1.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 9.3 kB

Release files / pytest_exasol_extension-1.1.0.tar.gz

Download URL pytest_exasol_extension-1.1.0.tar.gz
Size 4.4 kB
Tags Source
SHA-256 checksum
How to use checksums
6f8eaf8df7841629c410869b6b7cd5c44e06438bcdba75563b3fbd820662779b
BLAKE2b-256 checksum
How to use checksums
e4d0306016e5bcfae6d6a1667e6940ef34a06bff27faef161274d1eac666dad5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.3.0 CPython/3.10.20 Linux/6.17.0-1020-azure

Release files / pytest_exasol_extension-1.1.0-py3-none-any.whl

Download URL pytest_exasol_extension-1.1.0-py3-none-any.whl
Size 5.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
60fa8a432b9bd2306395b6c1d1255ae47e165d71eb8d03bbc4f3dc3fd091de05
BLAKE2b-256 checksum
How to use checksums
fa237e122f17208f7a359fd3cc653cffe448b64d2b9727506310cf3923e46e0e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.3.0 CPython/3.10.20 Linux/6.17.0-1020-azure

Security for pytest-exasol-extension 1.1.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