Skip to main content

No project description provided

Project description

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.

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

pytest_exasol_extension-1.0.0.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

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

pytest_exasol_extension-1.0.0-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file pytest_exasol_extension-1.0.0.tar.gz.

File metadata

  • Download URL: pytest_exasol_extension-1.0.0.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.0 CPython/3.10.19 Linux/6.11.0-1018-azure

File hashes

Hashes for pytest_exasol_extension-1.0.0.tar.gz
Algorithm Hash digest
SHA256 60a1a2a661ecd972a9dc6bb07529f7bca8877fde4220531e6aa70c65c187402c
MD5 e414843b6b8cf9bf28b4f13a34212322
BLAKE2b-256 78e07fbff4fbff52d9ee7cae3471730624468269557ecfba0099900baed4c5e6

See more details on using hashes here.

File details

Details for the file pytest_exasol_extension-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pytest_exasol_extension-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 80e411a57149bd1572ae12478d0899ca9c613d11c812780c04df8750d71c09d8
MD5 cfc178d3c5e3ed9a85e7f946210c32e9
BLAKE2b-256 6e9935c148ba4e5cc169ddb562bee8d6a4fdc9876fc6d8cea89c0dc2dbe4ca6b

See more details on using hashes here.

Supported by

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