neofs-testlib


Nameneofs-testlib JSON
Version 1.1.26 PyPI version JSON
download
home_pageNone
SummaryBuilding blocks and utilities to facilitate development of automated tests for NeoFS system
upload_time2024-03-25 00:30:49
maintainerNone
docs_urlNone
authorNone
requires_python>=3.10
licenseGNU General Public License v3 (GPLv3)
keywords neofs test
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # neofs-testlib
This library provides building blocks and utilities to facilitate development of automated tests for NeoFS system.

## Installation
Library can be installed via pip:
```shell
$ pip install neofs-testlib
```

## Configuration
Some library components support configuration that allows dynamic loading of extensions via plugins. Configuration of such components is described in this section.

### Reporter Configuration
Reporter is a singleton component that is used by the library to store test artifacts.

Reporter sends artifacts to handlers that are responsible for actual storing in particular system. By default reporter is initialized without any handlers and won't take any actions to store the artifacts. To add handlers directly via code you can use method `register_handler`:

```python
from neofs_testlib.reporter import AllureHandler, get_reporter

get_reporter().register_handler(AllureHandler())
```

This registration should happen early at the test session, because any artifacts produced before handler is registered won't be stored anywhere.

Alternative approach for registering handlers is to use method `configure`. It is similar to method [dictConfig](https://docs.python.org/3/library/logging.config.html#logging.config.dictConfig) in a sense that it receives a config structure that describes handlers that should be registered in the reporter. Each handler is defined by it's plugin name; for example, to register the built-in Allure handler, we can use the following config:

```python
get_reporter().configure({ "handlers": [{"plugin_name": "allure"}] })
```

### Hosting Configuration
Hosting component is a class that represents infrastructure (machines/containers/services) where neoFS is hosted. Interaction with specific infrastructure instance (host) is encapsulated in classes that implement interface `neofs_testlib.hosting.Host`. To pass information about hosts to the `Hosting` class in runtime we use method `configure`:

```python
from neofs_testlib.hosting import Hosting

hosting = Hosting()
hosting.configure({ "hosts": [{ "address": "localhost", "plugin_name": "docker" ... }]})
```

## Plugins
Testlib uses [entrypoint specification](https://docs.python.org/3/library/importlib.metadata.html) for plugins. Testlib supports the following entrypoint groups for plugins:
 - `neofs.testlib.reporter` - group for reporter handler plugins. Plugin should be a class that implements interface `neofs_testlib.reporter.interfaces.ReporterHandler`.

### Example reporter plugin
In this example we will consider two Python projects:
 - Project "my_neofs_plugins" where we will build a plugin that extends testlib functionality.
 - Project "my_neofs_tests" that uses "neofs_testlib" and "my_neofs_plugins" to build some tests.

Let's say we want to implement some custom reporter handler that can be used as a plugin for testlib. Pseudo-code of implementation can look like that:
```python
# File my_neofs_plugins/src/foo/bar/custom_handler.py
from contextlib import AbstractContextManager
from neofs_testlib.reporter import ReporterHandler


class CustomHandler(ReporterHandler):
    def step(self, name: str) -> AbstractContextManager:
        ... some implementation ...

    def attach(self, content: Any, file_name: str) -> None:
        ... some implementation ...
```

Then in the file `pyproject.toml` of "my_neofs_plugins" we should register entrypoint for this plugin. Entrypoint must belong to the group `neofs.testlib.reporter`:
```yaml
# File my_neofs_plugins/pyproject.toml
[project.entry-points."neofs.testlib.reporter"]
my_custom_handler = "foo.bar.custom_handler:CustomHandler"
```

Finally, to use this handler in our test project "my_neofs_tests", we should configure reporter with name of the handler plugin:

```python
# File my_neofs_tests/src/conftest.py
from neofs_testlib.reporter import get_reporter

get_reporter().configure({ "handlers": [{"plugin_name": "my_custom_handler"}] })
```

Detailed information about registering entrypoints can be found at [setuptools docs](https://setuptools.pypa.io/en/latest/userguide/entry_point.html).

## Library structure
The library provides the following primary components:
 * `blockchain` - Contains helpers that allow to interact with neo blockchain, smart contracts, gas transfers, etc.
 * `cli` - wrappers on top of neoFS command-line tools. These wrappers execute on a shell and provide type-safe interface for interacting with the tools.
 * `hosting` - management of infrastructure (docker, virtual machines, services where neoFS is hosted). The library provides host implementation for docker environment (when neoFS services are running as docker containers). Support for other hosts is provided via plugins.
 * `reporter` - abstraction on top of test reporting tool like Allure. Components of the library will report their steps and attach artifacts to the configured reporter instance.
 * `shell` - shells that can be used to execute commands. Currently library provides local shell (on machine that runs the code) or SSH shell that connects to a remote machine via SSH.
 * `utils` - Support functions.
 

## Contributing
Any contributions to the library should conform to the [contribution guideline](https://github.com/nspcc-dev/neofs-testlib/blob/master/CONTRIBUTING.md).

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "neofs-testlib",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": "neofs, test",
    "author": null,
    "author_email": "NSPCC <info@nspcc.ru>",
    "download_url": "https://files.pythonhosted.org/packages/61/0a/c3d1af9b3b78bca30b03e1c4ade70c3c5e52df8f7e00c0c07b068374f395/neofs-testlib-1.1.26.tar.gz",
    "platform": null,
    "description": "# neofs-testlib\nThis library provides building blocks and utilities to facilitate development of automated tests for NeoFS system.\n\n## Installation\nLibrary can be installed via pip:\n```shell\n$ pip install neofs-testlib\n```\n\n## Configuration\nSome library components support configuration that allows dynamic loading of extensions via plugins. Configuration of such components is described in this section.\n\n### Reporter Configuration\nReporter is a singleton component that is used by the library to store test artifacts.\n\nReporter sends artifacts to handlers that are responsible for actual storing in particular system. By default reporter is initialized without any handlers and won't take any actions to store the artifacts. To add handlers directly via code you can use method `register_handler`:\n\n```python\nfrom neofs_testlib.reporter import AllureHandler, get_reporter\n\nget_reporter().register_handler(AllureHandler())\n```\n\nThis registration should happen early at the test session, because any artifacts produced before handler is registered won't be stored anywhere.\n\nAlternative approach for registering handlers is to use method `configure`. It is similar to method [dictConfig](https://docs.python.org/3/library/logging.config.html#logging.config.dictConfig) in a sense that it receives a config structure that describes handlers that should be registered in the reporter. Each handler is defined by it's plugin name; for example, to register the built-in Allure handler, we can use the following config:\n\n```python\nget_reporter().configure({ \"handlers\": [{\"plugin_name\": \"allure\"}] })\n```\n\n### Hosting Configuration\nHosting component is a class that represents infrastructure (machines/containers/services) where neoFS is hosted. Interaction with specific infrastructure instance (host) is encapsulated in classes that implement interface `neofs_testlib.hosting.Host`. To pass information about hosts to the `Hosting` class in runtime we use method `configure`:\n\n```python\nfrom neofs_testlib.hosting import Hosting\n\nhosting = Hosting()\nhosting.configure({ \"hosts\": [{ \"address\": \"localhost\", \"plugin_name\": \"docker\" ... }]})\n```\n\n## Plugins\nTestlib uses [entrypoint specification](https://docs.python.org/3/library/importlib.metadata.html) for plugins. Testlib supports the following entrypoint groups for plugins:\n - `neofs.testlib.reporter` - group for reporter handler plugins. Plugin should be a class that implements interface `neofs_testlib.reporter.interfaces.ReporterHandler`.\n\n### Example reporter plugin\nIn this example we will consider two Python projects:\n - Project \"my_neofs_plugins\" where we will build a plugin that extends testlib functionality.\n - Project \"my_neofs_tests\" that uses \"neofs_testlib\" and \"my_neofs_plugins\" to build some tests.\n\nLet's say we want to implement some custom reporter handler that can be used as a plugin for testlib. Pseudo-code of implementation can look like that:\n```python\n# File my_neofs_plugins/src/foo/bar/custom_handler.py\nfrom contextlib import AbstractContextManager\nfrom neofs_testlib.reporter import ReporterHandler\n\n\nclass CustomHandler(ReporterHandler):\n    def step(self, name: str) -> AbstractContextManager:\n        ... some implementation ...\n\n    def attach(self, content: Any, file_name: str) -> None:\n        ... some implementation ...\n```\n\nThen in the file `pyproject.toml` of \"my_neofs_plugins\" we should register entrypoint for this plugin. Entrypoint must belong to the group `neofs.testlib.reporter`:\n```yaml\n# File my_neofs_plugins/pyproject.toml\n[project.entry-points.\"neofs.testlib.reporter\"]\nmy_custom_handler = \"foo.bar.custom_handler:CustomHandler\"\n```\n\nFinally, to use this handler in our test project \"my_neofs_tests\", we should configure reporter with name of the handler plugin:\n\n```python\n# File my_neofs_tests/src/conftest.py\nfrom neofs_testlib.reporter import get_reporter\n\nget_reporter().configure({ \"handlers\": [{\"plugin_name\": \"my_custom_handler\"}] })\n```\n\nDetailed information about registering entrypoints can be found at [setuptools docs](https://setuptools.pypa.io/en/latest/userguide/entry_point.html).\n\n## Library structure\nThe library provides the following primary components:\n * `blockchain` - Contains helpers that allow to interact with neo blockchain, smart contracts, gas transfers, etc.\n * `cli` - wrappers on top of neoFS command-line tools. These wrappers execute on a shell and provide type-safe interface for interacting with the tools.\n * `hosting` - management of infrastructure (docker, virtual machines, services where neoFS is hosted). The library provides host implementation for docker environment (when neoFS services are running as docker containers). Support for other hosts is provided via plugins.\n * `reporter` - abstraction on top of test reporting tool like Allure. Components of the library will report their steps and attach artifacts to the configured reporter instance.\n * `shell` - shells that can be used to execute commands. Currently library provides local shell (on machine that runs the code) or SSH shell that connects to a remote machine via SSH.\n * `utils` - Support functions.\n \n\n## Contributing\nAny contributions to the library should conform to the [contribution guideline](https://github.com/nspcc-dev/neofs-testlib/blob/master/CONTRIBUTING.md).\n",
    "bugtrack_url": null,
    "license": "GNU General Public License v3 (GPLv3)",
    "summary": "Building blocks and utilities to facilitate development of automated tests for NeoFS system",
    "version": "1.1.26",
    "project_urls": {
        "Homepage": "https://github.com/nspcc-dev/neofs-testlib"
    },
    "split_keywords": [
        "neofs",
        " test"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e5c155fc6d285cb61d96df16357d9f1dd9760f4d4b9d69b18c9551054a86e9a2",
                "md5": "821406d8c497dfe28d9b9e91d4e888bf",
                "sha256": "3b61684533eff31ffe4dfa9d3880b5df601f1184b7dfa2ff3be73e45698cf982"
            },
            "downloads": -1,
            "filename": "neofs_testlib-1.1.26-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "821406d8c497dfe28d9b9e91d4e888bf",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 86158,
            "upload_time": "2024-03-25T00:30:47",
            "upload_time_iso_8601": "2024-03-25T00:30:47.933116Z",
            "url": "https://files.pythonhosted.org/packages/e5/c1/55fc6d285cb61d96df16357d9f1dd9760f4d4b9d69b18c9551054a86e9a2/neofs_testlib-1.1.26-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "610ac3d1af9b3b78bca30b03e1c4ade70c3c5e52df8f7e00c0c07b068374f395",
                "md5": "63f22296d3a2fa8b854f30d623ccb8c4",
                "sha256": "49c0db757784bedb56c29f0acde0b77015150d0c84271bedb4c93476c8cb701d"
            },
            "downloads": -1,
            "filename": "neofs-testlib-1.1.26.tar.gz",
            "has_sig": false,
            "md5_digest": "63f22296d3a2fa8b854f30d623ccb8c4",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 69165,
            "upload_time": "2024-03-25T00:30:49",
            "upload_time_iso_8601": "2024-03-25T00:30:49.377711Z",
            "url": "https://files.pythonhosted.org/packages/61/0a/c3d1af9b3b78bca30b03e1c4ade70c3c5e52df8f7e00c0c07b068374f395/neofs-testlib-1.1.26.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-25 00:30:49",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "nspcc-dev",
    "github_project": "neofs-testlib",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "neofs-testlib"
}
        
Elapsed time: 0.21234s