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.
- 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.
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.2.1.tar.gz.
File metadata
- Download URL: pytest_exasol_backend-0.2.1.tar.gz
- Upload date:
- Size: 9.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.10.14 Linux/5.15.0-1071-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
176439cb59732e4b1f03c290c66c8b6799914615c8089dc4e901bdbbf50bf140
|
|
| MD5 |
67f67160361635a9f469f112f0d4fd04
|
|
| BLAKE2b-256 |
b3f1df0f04a93cde3fa40b769986e21ade4fd29f7c5c8d5a4d9f5e412b9bbb72
|
File details
Details for the file pytest_exasol_backend-0.2.1-py3-none-any.whl.
File metadata
- Download URL: pytest_exasol_backend-0.2.1-py3-none-any.whl
- Upload date:
- Size: 10.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.10.14 Linux/5.15.0-1071-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dba4925f60ffe7306b7494aaef52d86e1c36d26e542eb52ba114f940970804dd
|
|
| MD5 |
9cc2582c776cbc20415ea561b6e7644e
|
|
| BLAKE2b-256 |
d889a688804560d310be4b774fe6642e77ad8ec559f418890d8ce3a1b7915af1
|