Name | pytest-exasol-backend JSON |
Version |
1.1.0
JSON |
| download |
home_page | None |
Summary | None |
upload_time | 2025-07-21 10:27:59 |
maintainer | None |
docs_url | None |
author | Mikhail Beck |
requires_python | <4.0,>=3.10 |
license | None |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# 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:
```shell
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.
```python
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.
```python
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.
```python
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.
```shell
pytest --backend=onprem my_test_suite.py
```
This following command runs the test on two backends.
```shell
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.
```shell
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(...)](https://github.com/exasol/integration-test-docker-environment/blob/92cc67b8f9ab78c52106c1c4ba19fe64811bcb2c/exasol_integration_test_docker_environment/lib/api/spawn_test_environment.py#L35)
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.
```shell
pytest --backend=onprem --itde-db-mem-size "8 GiB" my_test_suite.py
```
These options are ignored if the "onprem" backend is not selected.
Raw data
{
"_id": null,
"home_page": null,
"name": "pytest-exasol-backend",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.10",
"maintainer_email": null,
"keywords": null,
"author": "Mikhail Beck",
"author_email": "mikhail.beck@exasol.com",
"download_url": "https://files.pythonhosted.org/packages/ed/a2/e98b2b782fdbd808210c9c4ceb1949da12a3b5f9c4bee4195f5d3c91afbf/pytest_exasol_backend-1.1.0.tar.gz",
"platform": null,
"description": "# pytest-exasol-backend Plugin\n\nThe `pytest-exasol-backend` plugin is a collection of pytest fixtures commonly used for testing\nprojects related to Exasol. In particular, it provides unified access to both Exasol On-Prem and\nSaaS backends. This eliminates the need to build different sets of tests for different backends.\n\n## Features\n\n* Provides session level fixtures that can be turned into connection factories for the database and the BucketFS.\n* Automatically makes the tests running on the selected backends.\n* Allows selecting either or both backends from the CLI that executes the pytest.\n* Starts the selected backends preemptively and in parallel.\n\n## Installation\n\nThe pytest-exasol-backend plugin can be installed using pip:\n\n```shell\npip install pytest-exasol-backend\n```\n\n## Usage in Tests\n\nBelow is an example of a test that requires access to the database. Note, that by default\nthis test will run twice - once for each backend.\n\n```python\nimport pyexasol\n\ndef test_number_of_rows_in_my_table(backend_aware_database_params):\n with pyexasol.connect(**backend_aware_database_params, schema='MY_SCHEMA') as conn:\n num_of_rows = conn.execute('SELECT COUNT(*) FROM MY_TABLE;').fetchval()\n assert num_of_rows == 5\n```\n\nHere is an example of a test that requires access to the BucketFS. Again, this test will\nrun for each backend, unless one of them is disabled in the CLI.\n\n```python\nimport exasol.bucketfs as bfs\n\ndef test_my_file_exists(backend_aware_bucketfs_params):\n my_bfs_dir = bfs.path.build_path(**backend_aware_bucketfs_params, path='MY_BFS_PATH')\n my_bfs_file = my_bfs_dir / 'my_file.dat'\n assert my_bfs_file.exists()\n```\n\nSometimes it may be necessary to know which backend the test is running with. In such\na case the `backend` fixture can be used, as in the example below.\n\n```python\ndef test_something_backend_sensitive(backend):\n if backend == 'onprem':\n # Do something special for the On-Prem database.\n pass\n elif backend == 'saas':\n # Do something special for the SaaS database.\n pass\n else:\n raise RuntimeError(f'Unknown backend {backend}')\n```\n\n## Selecting Backends in CLI\n\nBy default, none of the backends is selected for testing. Please use the `--backend` option to specify the target backend.\nThe command below runs the tests on an on-prem database.\n\n```shell\npytest --backend=onprem my_test_suite.py\n```\n\nThis following command runs the test on two backends.\n\n```shell\npytest --backend=onprem --backend=saas my_test_suite.py\n```\n\nThe next command runs the test on all backends, which currently is equivalent to the previous command since there\nare only two backends available.\n\n```shell\npytest --backend=all my_test_suite.py\n```\n\nPlease note that all selected backends starts preemptively, regardless of their actual usage in tests.\nTherefore, it is important to make sure the backends are not selected where they are not needed,\nfor instance when running unit tests only.\n\n## Setting ITDE parameters in CLI\n\nSometimes the default ITDE parameters cannot satisfy the test requirements. The plugin allows setting\nsome of the parameters of the [api.spawn_test_environment(...)](https://github.com/exasol/integration-test-docker-environment/blob/92cc67b8f9ab78c52106c1c4ba19fe64811bcb2c/exasol_integration_test_docker_environment/lib/api/spawn_test_environment.py#L35)\nfunction. The parameter values can be provided in the CLI options. Currently, it is possible to set values of the following parameters:\n - `--itde-db-mem-size`\n - `--itde-db-disk-size`\n - `--itde-nameserver`\n - `--itde-db-version`\n\nIn the example below the tests are run using an instance of the DockerDB with increased memory.\n\n```shell\npytest --backend=onprem --itde-db-mem-size \"8 GiB\" my_test_suite.py\n```\n\nThese options are ignored if the \"onprem\" backend is not selected.\n",
"bugtrack_url": null,
"license": null,
"summary": null,
"version": "1.1.0",
"project_urls": null,
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "7e584ae7934ac0d5767230f208988ffba2c70c0fda070a8b8214d1f1ff581ddb",
"md5": "1d76f8e8f8f1ed1bec7fe5e031fc1143",
"sha256": "89c8f74d5e092595e92a9a5e4cfbd9182d8748246822355bd3179e97cb1fd899"
},
"downloads": -1,
"filename": "pytest_exasol_backend-1.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "1d76f8e8f8f1ed1bec7fe5e031fc1143",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.10",
"size": 12329,
"upload_time": "2025-07-21T10:27:58",
"upload_time_iso_8601": "2025-07-21T10:27:58.683840Z",
"url": "https://files.pythonhosted.org/packages/7e/58/4ae7934ac0d5767230f208988ffba2c70c0fda070a8b8214d1f1ff581ddb/pytest_exasol_backend-1.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "eda2e98b2b782fdbd808210c9c4ceb1949da12a3b5f9c4bee4195f5d3c91afbf",
"md5": "9df40b80742a7319abad081be8d8e029",
"sha256": "ae00ab25078fc56b727e74b80c622b2e0053de84bbebb78e04118826abb733fc"
},
"downloads": -1,
"filename": "pytest_exasol_backend-1.1.0.tar.gz",
"has_sig": false,
"md5_digest": "9df40b80742a7319abad081be8d8e029",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.10",
"size": 11143,
"upload_time": "2025-07-21T10:27:59",
"upload_time_iso_8601": "2025-07-21T10:27:59.808048Z",
"url": "https://files.pythonhosted.org/packages/ed/a2/e98b2b782fdbd808210c9c4ceb1949da12a3b5f9c4bee4195f5d3c91afbf/pytest_exasol_backend-1.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-07-21 10:27:59",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "pytest-exasol-backend"
}