Name | pytest-exasol-extension JSON |
Version |
0.2.1
JSON |
| download |
home_page | None |
Summary | None |
upload_time | 2024-10-10 18:30:41 |
maintainer | None |
docs_url | None |
author | Mikhail Beck |
requires_python | <4,>=3.10 |
license | None |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# 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:
```shell
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.
```python
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.
```python
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.
```python
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.
Raw data
{
"_id": null,
"home_page": null,
"name": "pytest-exasol-extension",
"maintainer": null,
"docs_url": null,
"requires_python": "<4,>=3.10",
"maintainer_email": null,
"keywords": null,
"author": "Mikhail Beck",
"author_email": "mikhail.beck@exasol.com",
"download_url": "https://files.pythonhosted.org/packages/b6/bd/6ba1b346c85348e7375f4715b0620742377d86bf8bff374ba3b8d45ff366/pytest_exasol_extension-0.2.1.tar.gz",
"platform": null,
"description": "# pytest-exasol-extension Plugin\n\nThe `pytest-exasol-extension` plugin provides pytest fixtures for preparing a database for the extension tests.\nThe fixtures are backend agnostic. They run for the selected backends\n(see the documentation for the `pytest-exasol-backend` plugin).\n\n## Installation\n\nThe pytest-exasol-extension plugin can be installed using pip:\n\n```shell\npip install pytest-exasol-extension\n```\n\n## Usage in Tests\n\nBelow is an example of a test that requires a database connection with an open test schema.\n\n```python\nimport pytest\n\n@pytest.fixture(scope=\"session\")\ndef db_schema_name() -> str:\n \"\"\"Let's override a randomly generated db schema for the test, giving it a meaningful name.\"\"\"\n return 'MY_TEST_SCHEMA'\n\ndef test_something(pyexasol_connection):\n ...\n```\n\nNext, is an example of a test that needs to store a bucket-fs connection object in the database.\n\n```python\ndef test_something_else(bucketfs_connection_factory):\n bucketfs_connection_factory('my_connection_name,' 'some_path/in_the_bucket')\n ...\n```\n\nThe following fixtures are used to test various deployment scenarios where the connection parameters\nfor the Database and the BucketFS are supplied in a command line. The first two fixtures provide dictionaries\nof standard cli parameters (`StdParams`) defined in the `exasol-python-extension-common`.\n\n `database_std_params` - the Database connection parameters.\n `bucketfs_std_params` - the BucketFs connection parameters.\n\nThe next two fixtures - `database_cli_args` and `bucketfs_cli_args` - give the same parameters as the previous two\nbut in the form of command line arguments. They are helpful for testing the CLI directly, for example using the\nclick.CliRunner as in the samples below. There is also a fixture - `cli_args` - that combines these two argument\nstrings.\n\n```python\nimport click\nfrom click.testing import CliRunner\nfrom exasol.python_extension_common.cli.std_options import (StdParams, StdTags, select_std_options)\nfrom exasol.pytest_backend import (BACKEND_ONPREM, BACKEND_SAAS)\n\ndef test_db_connection_cli(backend, database_cli_args):\n if backend == BACKEND_ONPREM:\n tags = StdTags.DB | StdTags.ONPREM\n elif backend == BACKEND_SAAS:\n tags = StdTags.DB | StdTags.SAAS\n else:\n ValueError(f'Unknown backend {backend}')\n\n def test_something_with_db(**kwargs):\n pass\n\n opts = select_std_options(tags)\n cmd = click.Command('whatever', params=opts, callback=test_something_with_db)\n runner = CliRunner()\n runner.invoke(cmd, args=database_cli_args, catch_exceptions=False, standalone_mode=False)\n\ndef test_bucketfs_connection_cli(backend, bucketfs_cli_args):\n if backend == BACKEND_ONPREM:\n tags = StdTags.BFS | StdTags.ONPREM\n elif backend == BACKEND_SAAS:\n tags = StdTags.BFS | StdTags.SAAS\n else:\n ValueError(f'Unknown backend {backend}')\n\n def test_something_with_bucketfs(**kwargs):\n pass\n\n opts = select_std_options(tags)\n cmd = click.Command('whatever', params=opts, callback=test_something_with_bucketfs)\n runner = CliRunner()\n runner.invoke(cmd, args=bucketfs_cli_args, catch_exceptions=False, standalone_mode=False)\n```\n\nNote, that by default the tests will run twice - once for each backend.\n",
"bugtrack_url": null,
"license": null,
"summary": null,
"version": "0.2.1",
"project_urls": null,
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "6d064e38ef8c60c96169774a2d31f80a650a63f91a1a7d7bf2682577daf8d115",
"md5": "89087633b12c48214ff7938d1aa0a9c9",
"sha256": "9ec0611872c865a1f97e2cbaedbd194919bc7a38cf91d228ab2c94d120abb6d0"
},
"downloads": -1,
"filename": "pytest_exasol_extension-0.2.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "89087633b12c48214ff7938d1aa0a9c9",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4,>=3.10",
"size": 5045,
"upload_time": "2024-10-10T18:30:40",
"upload_time_iso_8601": "2024-10-10T18:30:40.884631Z",
"url": "https://files.pythonhosted.org/packages/6d/06/4e38ef8c60c96169774a2d31f80a650a63f91a1a7d7bf2682577daf8d115/pytest_exasol_extension-0.2.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "b6bd6ba1b346c85348e7375f4715b0620742377d86bf8bff374ba3b8d45ff366",
"md5": "540464dcaf180f3310c83708f9419d2a",
"sha256": "b628cb8f5505a20ca39e9828afa2a7f50bfbbfc55b9203b12c453527e9718ab3"
},
"downloads": -1,
"filename": "pytest_exasol_extension-0.2.1.tar.gz",
"has_sig": false,
"md5_digest": "540464dcaf180f3310c83708f9419d2a",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4,>=3.10",
"size": 4231,
"upload_time": "2024-10-10T18:30:41",
"upload_time_iso_8601": "2024-10-10T18:30:41.756039Z",
"url": "https://files.pythonhosted.org/packages/b6/bd/6ba1b346c85348e7375f4715b0620742377d86bf8bff374ba3b8d45ff366/pytest_exasol_extension-0.2.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-10-10 18:30:41",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "pytest-exasol-extension"
}