No project description provided
Project description
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.
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, both backends are selected for testing. To run the tests on one backed only,
the --backend option can be used. The command below runs the tests on an on-prem database.
pytest --backend=onprem my_test_suite.py
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pytest_exasol_backend-0.1.0.tar.gz.
File metadata
- Download URL: pytest_exasol_backend-0.1.0.tar.gz
- Upload date:
- Size: 7.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.9.19 Linux/5.15.0-1070-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c3d831eed3ead7c43d6ee450f7ed9132e9eae5fccd7a1455d95d1631aece1e55
|
|
| MD5 |
daf98fb28d196c7c9e6592a50b198438
|
|
| BLAKE2b-256 |
b22e109688d4ab0919b63ff51223388f6c6c6668756ca7c84790fc2049269488
|
File details
Details for the file pytest_exasol_backend-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pytest_exasol_backend-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.9.19 Linux/5.15.0-1070-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
72e89d1629838c73e47bd409e5ca1b95e94649995021e2b55aa7fd10a46533c6
|
|
| MD5 |
00553bfdd8d99a13e13041074d0c76a3
|
|
| BLAKE2b-256 |
79a8bb2dff7a9639c3ab5d44a6dfcd6525a3cecbec10c94a4cc6434da7e4c7d8
|