.. image:: https://raw.githubusercontent.com/ClearcodeHQ/pytest-elasticsearch/master/logo.png
:width: 100px
:height: 100px
pytest-elasticsearch
====================
.. image:: https://img.shields.io/pypi/v/pytest-elasticsearch.svg
:target: https://pypi.python.org/pypi/pytest-elasticsearch/
:alt: Latest PyPI version
.. image:: https://img.shields.io/pypi/wheel/pytest-elasticsearch.svg
:target: https://pypi.python.org/pypi/pytest-elasticsearch/
:alt: Wheel Status
.. image:: https://img.shields.io/pypi/pyversions/pytest-elasticsearch.svg
:target: https://pypi.python.org/pypi/pytest-elasticsearch/
:alt: Supported Python Versions
.. image:: https://img.shields.io/pypi/l/pytest-elasticsearch.svg
:target: https://pypi.python.org/pypi/pytest-elasticsearch/
:alt: License
What is this?
=============
This is a pytest plugin that enables you to test your code that relies on a running Elasticsearch search engine.
It allows you to specify fixtures for Elasticsearch process and client.
How to use
==========
.. warning::
This plugin requires at least version 6.0 of elasticsearch to work.
The plugin contains two fixtures:
* **elasticsearch** - a client fixture that has functional scope, and which
cleans Elasticsearch at the end of each test.
* **elasticsearch_proc** - a session scoped fixture, that starts Elasticsearch
instance at its first use and stops at the end of the tests.
* **elasticsearch_nooproc** - a nooprocess fixture, that's holds connection data
to already running elasticsearch
Simply include one of these fixtures into your tests fixture list.
You can also create additional elasticsearch client and process fixtures if you'd need to:
.. code-block:: python
from pytest_elasticsearch import factories
elasticsearch_my_proc = factories.elasticsearch_proc(port=None)
elasticsearch_my = factories.elasticsearch('elasticsearch_my_proc')
.. note::
Each elasticsearch process fixture can be configured in a different way than the others through the fixture factory arguments.
Connecting to already existing Elasticsearch service
----------------------------------------------------
Some projects are using already running Elasticsearch servers
(ie on docker instances). In order to connect to them, one would be using the
``elasticsearch_nooproc`` fixture.
.. code-block:: python
es_external = factories.elasticsearch('elasticsearch_nooproc')
By default the ``elasticsearch_nooproc`` fixture would connect to elasticsearch
instance using **9300** port.
Configuration
=============
You can define your settings in three ways, it's fixture factory argument, command line option and pytest.ini configuration option.
You can pick which you prefer, but remember that these settings are handled in the following order:
1. Fixture factory argument
2. Command line option
3. Configuration option in your pytest.ini file
.. list-table:: Configuration options
:header-rows: 1
* - ElasticSearch option
- Fixture factory argument
- Command line option
- pytest.ini option
- Noop process fixture
- Default
* - Elasticsearch executable
- executable
- --elasticsearch-executable
- elasticsearch_executable
-
- /usr/share/elasticsearch/bin/elasticsearch
* - host
- host
- --elasticsearch-host
- elasticsearch_host
- host
- 127.0.0.1
* - port
- port
- --elasticsearch-port
- elasticsearch_port
- 6300
- random
* - Elasticsearch cluster name
- cluster_name
- --elasticsearch-cluster-name
- elasticsearch_cluster_name
- -
- elasticsearch_cluster_<port>
* - index storage type
- index_store_type
- --elasticsearch-index-store-type
- elasticsearch_index_store_type
- -
- mmapfs
* - network publish host
- network_publish_host
- --elasticsearch-network-publish-host
- elasticsearch_network_publish_host
- -
- 127.0.0.1
* - transport tcp port
- transport_tcp_port
- --elasticsearch-transport-tcp-port
- elasticsearch_transport_tcp_port
- -
- random
Example usage:
* pass it as an argument in your own fixture
.. code-block:: python
elasticsearch_proc = factories.elasticsearch_proc(
cluster_name='awsome_cluster)
* specify your directory as ``elasticsearch_cluster_name`` in your ``pytest.ini`` file.
To do so, put a line like the following under the ``[pytest]`` section of your ``pytest.ini``:
.. code-block:: ini
[pytest]
elasticsearch_cluster_name = awsome_cluster
Known issues
------------
It might happen, that the process can't be started due to lack of permissions.
The files that user running tests has to have access to are:
* /etc/default/elasticsearch
Make sure that you either run tests as a user that has access to these files,
or you give user proper permissions or add it to proper user groups.
In CI at the moment, we install elasticsearch from tar/zip archives,
which do not set up additional permission restrictions, so it's not a problem on the CI/CD.
Package resources
-----------------
* Bug tracker: https://github.com/ClearcodeHQ/pytest-elasticsearch/issues
Raw data
{
"_id": null,
"home_page": null,
"name": "pytest-elasticsearch",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": "tests, pytest, fixture, elasticsearch",
"author": null,
"author_email": "Grzegorz \u015aliwi\u0144ski <fizyk+pypi@fizyk.dev>",
"download_url": "https://files.pythonhosted.org/packages/93/64/3023f84b0e975273872ab3bec42e14530d7a7449689843dc67f210ae250a/pytest_elasticsearch-4.1.1.tar.gz",
"platform": null,
"description": "\n.. image:: https://raw.githubusercontent.com/ClearcodeHQ/pytest-elasticsearch/master/logo.png\n :width: 100px\n :height: 100px\n \npytest-elasticsearch\n====================\n\n.. image:: https://img.shields.io/pypi/v/pytest-elasticsearch.svg\n :target: https://pypi.python.org/pypi/pytest-elasticsearch/\n :alt: Latest PyPI version\n\n.. image:: https://img.shields.io/pypi/wheel/pytest-elasticsearch.svg\n :target: https://pypi.python.org/pypi/pytest-elasticsearch/\n :alt: Wheel Status\n\n.. image:: https://img.shields.io/pypi/pyversions/pytest-elasticsearch.svg\n :target: https://pypi.python.org/pypi/pytest-elasticsearch/\n :alt: Supported Python Versions\n\n.. image:: https://img.shields.io/pypi/l/pytest-elasticsearch.svg\n :target: https://pypi.python.org/pypi/pytest-elasticsearch/\n :alt: License\n\nWhat is this?\n=============\n\nThis is a pytest plugin that enables you to test your code that relies on a running Elasticsearch search engine.\nIt allows you to specify fixtures for Elasticsearch process and client.\n\nHow to use\n==========\n\n.. warning::\n\n This plugin requires at least version 6.0 of elasticsearch to work.\n\nThe plugin contains two fixtures:\n\n* **elasticsearch** - a client fixture that has functional scope, and which\n cleans Elasticsearch at the end of each test.\n* **elasticsearch_proc** - a session scoped fixture, that starts Elasticsearch\n instance at its first use and stops at the end of the tests.\n* **elasticsearch_nooproc** - a nooprocess fixture, that's holds connection data\n to already running elasticsearch\n\nSimply include one of these fixtures into your tests fixture list.\n\nYou can also create additional elasticsearch client and process fixtures if you'd need to:\n\n\n.. code-block:: python\n\n from pytest_elasticsearch import factories\n\n elasticsearch_my_proc = factories.elasticsearch_proc(port=None)\n elasticsearch_my = factories.elasticsearch('elasticsearch_my_proc')\n\n.. note::\n\n Each elasticsearch process fixture can be configured in a different way than the others through the fixture factory arguments.\n\n\nConnecting to already existing Elasticsearch service\n----------------------------------------------------\n\nSome projects are using already running Elasticsearch servers\n(ie on docker instances). In order to connect to them, one would be using the\n``elasticsearch_nooproc`` fixture.\n\n.. code-block:: python\n\n es_external = factories.elasticsearch('elasticsearch_nooproc')\n\nBy default the ``elasticsearch_nooproc`` fixture would connect to elasticsearch\ninstance using **9300** port.\n\nConfiguration\n=============\n\nYou can define your settings in three ways, it's fixture factory argument, command line option and pytest.ini configuration option.\nYou can pick which you prefer, but remember that these settings are handled in the following order:\n\n1. Fixture factory argument\n2. Command line option\n3. Configuration option in your pytest.ini file\n\n.. list-table:: Configuration options\n :header-rows: 1\n\n * - ElasticSearch option\n - Fixture factory argument\n - Command line option\n - pytest.ini option\n - Noop process fixture\n - Default\n * - Elasticsearch executable\n - executable\n - --elasticsearch-executable\n - elasticsearch_executable\n -\n - /usr/share/elasticsearch/bin/elasticsearch\n * - host\n - host\n - --elasticsearch-host\n - elasticsearch_host\n - host\n - 127.0.0.1\n * - port\n - port\n - --elasticsearch-port\n - elasticsearch_port\n - 6300\n - random\n * - Elasticsearch cluster name\n - cluster_name\n - --elasticsearch-cluster-name\n - elasticsearch_cluster_name\n - -\n - elasticsearch_cluster_<port>\n * - index storage type\n - index_store_type\n - --elasticsearch-index-store-type\n - elasticsearch_index_store_type\n - -\n - mmapfs\n * - network publish host\n - network_publish_host\n - --elasticsearch-network-publish-host\n - elasticsearch_network_publish_host\n - -\n - 127.0.0.1\n * - transport tcp port\n - transport_tcp_port\n - --elasticsearch-transport-tcp-port\n - elasticsearch_transport_tcp_port\n - -\n - random\n\nExample usage:\n\n* pass it as an argument in your own fixture\n\n .. code-block:: python\n\n elasticsearch_proc = factories.elasticsearch_proc(\n cluster_name='awsome_cluster)\n\n\n* specify your directory as ``elasticsearch_cluster_name`` in your ``pytest.ini`` file.\n\n To do so, put a line like the following under the ``[pytest]`` section of your ``pytest.ini``:\n\n .. code-block:: ini\n\n [pytest]\n elasticsearch_cluster_name = awsome_cluster\n\nKnown issues\n------------\n\nIt might happen, that the process can't be started due to lack of permissions.\nThe files that user running tests has to have access to are:\n\n* /etc/default/elasticsearch\n\nMake sure that you either run tests as a user that has access to these files,\nor you give user proper permissions or add it to proper user groups.\n\nIn CI at the moment, we install elasticsearch from tar/zip archives,\nwhich do not set up additional permission restrictions, so it's not a problem on the CI/CD.\n\nPackage resources\n-----------------\n\n* Bug tracker: https://github.com/ClearcodeHQ/pytest-elasticsearch/issues\n",
"bugtrack_url": null,
"license": null,
"summary": "Elasticsearch fixtures and fixture factories for Pytest.",
"version": "4.1.1",
"project_urls": {
"Bug Tracker": "https://github.com/ClearcodeHQ/pytest-elasticsearch/issues",
"Changelog": "https://github.com/ClearcodeHQ/pytest-elasticsearch/blob/v4.1.1/CHANGES.rst",
"Source": "https://github.com/ClearcodeHQ/pytest-elasticsearch"
},
"split_keywords": [
"tests",
" pytest",
" fixture",
" elasticsearch"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "45f5654716730d440f4193bae94f62edf771ffbee0093c133aa79deb466663cb",
"md5": "dc56800a417892a17a57acde048999e1",
"sha256": "a2a8b450f8b79742938763ba2996f055b11c0f29be619a5ec71d607031eee8a7"
},
"downloads": -1,
"filename": "pytest_elasticsearch-4.1.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "dc56800a417892a17a57acde048999e1",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 26051,
"upload_time": "2024-12-03T09:34:50",
"upload_time_iso_8601": "2024-12-03T09:34:50.964857Z",
"url": "https://files.pythonhosted.org/packages/45/f5/654716730d440f4193bae94f62edf771ffbee0093c133aa79deb466663cb/pytest_elasticsearch-4.1.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "93643023f84b0e975273872ab3bec42e14530d7a7449689843dc67f210ae250a",
"md5": "d1f53fddc1e41821f98409b008de1ca0",
"sha256": "b715f2782b1f947cbf662d7034bb47f282010e37a3ed2f32fbc2b8c4303cbd74"
},
"downloads": -1,
"filename": "pytest_elasticsearch-4.1.1.tar.gz",
"has_sig": false,
"md5_digest": "d1f53fddc1e41821f98409b008de1ca0",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 27571,
"upload_time": "2024-12-03T09:34:52",
"upload_time_iso_8601": "2024-12-03T09:34:52.633469Z",
"url": "https://files.pythonhosted.org/packages/93/64/3023f84b0e975273872ab3bec42e14530d7a7449689843dc67f210ae250a/pytest_elasticsearch-4.1.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-03 09:34:52",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "ClearcodeHQ",
"github_project": "pytest-elasticsearch",
"travis_ci": false,
"coveralls": true,
"github_actions": true,
"lcname": "pytest-elasticsearch"
}