im-swagger-spy


Nameim-swagger-spy JSON
Version 0.4.0 PyPI version JSON
download
home_page
Summaryim-swagger-spy: pytest plugin for matching methods in swagger with those used in tests
upload_time2023-09-07 09:27:44
maintainer
docs_urlNone
author
requires_python>=3.8
license
keywords plugin pytest pytest plugin requests swagger
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # im-swagger-spy

pytest plugin for matching methods in swagger with those used in tests

## Установка

```bash
pip install git+https://github.com/dasshit/im-swagger-spy.git
```

## Использование

Есть несколько вариантов использования

### Вариант №1

pytest.ini
```ini
[pytest]
addopts = --swagger-url http://localhost/client/v101/u/api.yaml # Адрес, с которого можно получить swagger.json|yaml или openapi.json|yaml
            --swagger-prefix /api/v101                          # Префикс к path методов из документации
            --swagger-name test.ru                              # Название сервиса (для отчета)
            --swagger-report  reports/                          # Путь к папке для сохранения отчета
```
conftest.py
```python
import pytest
import requests


@pytest.fixture(scope='session')
def session(swagger_http_spy):

    session = requests.Session()

    swagger_http_spy.register_as_hook(session)

    yield session # Запросы этой сессии попадут в отчет
``` 
CI
```bash
pytest tests/
python -m im_swagger_spy build
```

### Другие примеры

Можно посмотреть в example/

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "im-swagger-spy",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "",
    "keywords": "plugin,pytest,pytest plugin,requests,swagger",
    "author": "",
    "author_email": "Korobov Valerii <v.korobov@corp.mail.ru>",
    "download_url": "https://files.pythonhosted.org/packages/31/dc/a9c06b03b40cca1be4b92de90a07b78315e7ba3a9189b718cff2d0d43e47/im_swagger_spy-0.4.0.tar.gz",
    "platform": null,
    "description": "# im-swagger-spy\n\npytest plugin for matching methods in swagger with those used in tests\n\n## \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430\n\n```bash\npip install git+https://github.com/dasshit/im-swagger-spy.git\n```\n\n## \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\n\n\u0415\u0441\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f\n\n### \u0412\u0430\u0440\u0438\u0430\u043d\u0442 \u21161\n\npytest.ini\n```ini\n[pytest]\naddopts = --swagger-url http://localhost/client/v101/u/api.yaml # \u0410\u0434\u0440\u0435\u0441, \u0441 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c swagger.json|yaml \u0438\u043b\u0438 openapi.json|yaml\n            --swagger-prefix /api/v101                          # \u041f\u0440\u0435\u0444\u0438\u043a\u0441 \u043a path \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0438\u0437 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438\n            --swagger-name test.ru                              # \u041d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0441\u0435\u0440\u0432\u0438\u0441\u0430 (\u0434\u043b\u044f \u043e\u0442\u0447\u0435\u0442\u0430)\n            --swagger-report  reports/                          # \u041f\u0443\u0442\u044c \u043a \u043f\u0430\u043f\u043a\u0435 \u0434\u043b\u044f \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043e\u0442\u0447\u0435\u0442\u0430\n```\nconftest.py\n```python\nimport pytest\nimport requests\n\n\n@pytest.fixture(scope='session')\ndef session(swagger_http_spy):\n\n    session = requests.Session()\n\n    swagger_http_spy.register_as_hook(session)\n\n    yield session # \u0417\u0430\u043f\u0440\u043e\u0441\u044b \u044d\u0442\u043e\u0439 \u0441\u0435\u0441\u0441\u0438\u0438 \u043f\u043e\u043f\u0430\u0434\u0443\u0442 \u0432 \u043e\u0442\u0447\u0435\u0442\n``` \nCI\n```bash\npytest tests/\npython -m im_swagger_spy build\n```\n\n### \u0414\u0440\u0443\u0433\u0438\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b\n\n\u041c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432 example/\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "im-swagger-spy: pytest plugin for matching methods in swagger with those used in tests",
    "version": "0.4.0",
    "project_urls": {
        "Homepage": "https://github.com/dasshit/im-swagger-spy",
        "Source": "https://github.com/dasshit/im-swagger-spy",
        "Tracker": "https://github.com/dasshit/im-swagger-spy/issues"
    },
    "split_keywords": [
        "plugin",
        "pytest",
        "pytest plugin",
        "requests",
        "swagger"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "cea9f3c1d9ab64d623164d28a8e4dbaf98a8c3b2367f3514bf0a5fcd33cb0d23",
                "md5": "74affa7f738b3029b212ac80317849d0",
                "sha256": "a20dd5c606e0e7930b9aeabb30055d4c2730fec614d4b1e60c1de3c43cba6a7e"
            },
            "downloads": -1,
            "filename": "im_swagger_spy-0.4.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "74affa7f738b3029b212ac80317849d0",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 10588,
            "upload_time": "2023-09-07T09:27:43",
            "upload_time_iso_8601": "2023-09-07T09:27:43.269907Z",
            "url": "https://files.pythonhosted.org/packages/ce/a9/f3c1d9ab64d623164d28a8e4dbaf98a8c3b2367f3514bf0a5fcd33cb0d23/im_swagger_spy-0.4.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "31dca9c06b03b40cca1be4b92de90a07b78315e7ba3a9189b718cff2d0d43e47",
                "md5": "72fe4f72bdcedb41cde4cd8e35af5c76",
                "sha256": "d88a5eab795e2b73fee6249f08b87fb0ac308c90ea96eef55c5164ce655b6c82"
            },
            "downloads": -1,
            "filename": "im_swagger_spy-0.4.0.tar.gz",
            "has_sig": false,
            "md5_digest": "72fe4f72bdcedb41cde4cd8e35af5c76",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 10446,
            "upload_time": "2023-09-07T09:27:44",
            "upload_time_iso_8601": "2023-09-07T09:27:44.961980Z",
            "url": "https://files.pythonhosted.org/packages/31/dc/a9c06b03b40cca1be4b92de90a07b78315e7ba3a9189b718cff2d0d43e47/im_swagger_spy-0.4.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-09-07 09:27:44",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "dasshit",
    "github_project": "im-swagger-spy",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "im-swagger-spy"
}
        
Elapsed time: 0.84710s