partest


Namepartest JSON
Version 0.2.0 PyPI version JSON
download
home_pagehttps://github.com/Dec01/partest
SummaryThis is a module for the rapid implementation of test cases with coverage tracking. This module contains a call counter for specific endpoints and their methods. As well as the function of determining the types of tests that need to be counted.
upload_time2025-01-12 10:26:40
maintainerNone
docs_urlNone
authordec01
requires_python>=3.8
licenseNone
keywords autotest partest test coverage
VCS
bugtrack_url
requirements attrs certifi charset-normalizer Faker idna iniconfig jsonschema packaging pluggy py pyparsing pyrsistent pytest python-dateutil requests six tomli urllib3 pytest-repeat pytest-asyncio pydantic pytest-rerunfailures ruff allure-pytest allure-python-commons httpx swagger-parser matplotlib pyyaml
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ## Partest

This is a framework for API autotests with coverage assessment. Detailed instructions in the process of writing. It is better to check with the author how to use it. Tools are used:

* pytest
* httpx
* allure

Files are required for specific work:

**conftest.py** - it must have a fixture's inside:

```commandline
def pytest_addoption(parser):
    parser.addoption("--domain", action="store", default="http://url.ru")

@pytest.fixture(scope="session")
def domain(request):
    return request.config.getoption("--domain")
    
@pytest.fixture(scope="session")
def api_client(domain):
    return ApiClient(domain=domain)

@pytest.fixture(scope='session', autouse=True)
def clear_call_data():
    global call_count, call_type
    api_call_storage.call_count.clear()
    api_call_storage.call_type.clear()
    yield
```

**confpartest.py** - It must have variables inside:

```
swagger_files = {
    'test1': ['local', '../docs/openapi.yaml']
}

test_types_coverage = ['default', '405', 'param']
test_types_exception = ['health']

    """ swagger_files
    
        The **swagger_files** directory can have many items. The item key is the name of the swagger. Next, let's analyze the value
        in which the list with certain data is stored:
            0: 'local' or 'url'
            1: 'path'
            
        Example:
        
        swagger_files = {
            'test1': ['url', 'https://petstore.swagger.io/v2/swagger.json'],
            'test2': ['local', '../docs/openapi.yaml']
        }

    """
    """ test_types_coverage
    
        The **test_types_coverage** a list of test types, the amount of which is 100% coverage. List of available types:

        'default': The default type of test case.
        '405': The type of test case for 405 error.
        'params': The type of test case for parameters.
        'elem': The type of test case for elements.
        'generation_data': The type of test case for generation data.
        'health': The type of test case for health.
        'env': The type of test case for environment.
        
    """
        """ test_types_exception
    
        The **test_types_exception** contains a list of test types that are an exception. Applying this type of test to 
        an endpoint automatically counts as 100% coverage.
        
    """
```

The project must have a test that displays information about the coverage in allure. The name of it **test_zorro.py**:

```commandline
import allure
import pytest

from partest.zorro_report import zorro

@pytest.mark.asyncio
class TestCoverAge:

    async def test_display_final_call_counts(self):
        zorro()
        assert True

```

What does the test look like:

```commandline
    async def test_get(self, api_client):
        endpoint = 'https://ya.ru'
        response = await api_client.make_request(
            'GET',
            endpoint,
            params='limit=1',
            expected_status_code=200,
            validate_model=Models.ValidateGet,
            type=types.type_default
        )
        assert response is not None
        assert isinstance(response, dict)
```

All available data that the client can accept:
```
        Parameters
        ----------
        :param method: HTTP method to use.
        :param endpoint: The endpoint to make the request to.
        :param add_url1: Additional URL part 1.
        :param add_url2: Additional URL part 2.
        :param add_url3: Additional URL part 3.
        :param after_url: Additional URL part after the endpoint.
        :param defining_url: Defining URL.
        :param params: Query parameters.
        :param headers: Request headers.
        :param data: Request data.
        :param data_type: Request data type.
        :param files: Request files.
        :param expected_status_code: Expected status code.
        :param validate_model: Model to validate the response.
        :param type: Request type.
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Dec01/partest",
    "name": "partest",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "autotest partest test coverage",
    "author": "dec01",
    "author_email": "parschin.ewg@yandex.ru",
    "download_url": "https://files.pythonhosted.org/packages/dd/12/86d54350c45480b9280722246a64acdb1472a80f83a4398c14c7dd568a9b/partest-0.2.0.tar.gz",
    "platform": null,
    "description": "## Partest\n\nThis is a framework for API autotests with coverage assessment. Detailed instructions in the process of writing. It is better to check with the author how to use it. Tools are used:\n\n* pytest\n* httpx\n* allure\n\nFiles are required for specific work:\n\n**conftest.py** - it must have a fixture's inside:\n\n```commandline\ndef pytest_addoption(parser):\n    parser.addoption(\"--domain\", action=\"store\", default=\"http://url.ru\")\n\n@pytest.fixture(scope=\"session\")\ndef domain(request):\n    return request.config.getoption(\"--domain\")\n    \n@pytest.fixture(scope=\"session\")\ndef api_client(domain):\n    return ApiClient(domain=domain)\n\n@pytest.fixture(scope='session', autouse=True)\ndef clear_call_data():\n    global call_count, call_type\n    api_call_storage.call_count.clear()\n    api_call_storage.call_type.clear()\n    yield\n```\n\n**confpartest.py** - It must have variables inside:\n\n```\nswagger_files = {\n    'test1': ['local', '../docs/openapi.yaml']\n}\n\ntest_types_coverage = ['default', '405', 'param']\ntest_types_exception = ['health']\n\n    \"\"\" swagger_files\n    \n        The **swagger_files** directory can have many items. The item key is the name of the swagger. Next, let's analyze the value\n        in which the list with certain data is stored:\n            0: 'local' or 'url'\n            1: 'path'\n            \n        Example:\n        \n        swagger_files = {\n            'test1': ['url', 'https://petstore.swagger.io/v2/swagger.json'],\n            'test2': ['local', '../docs/openapi.yaml']\n        }\n\n    \"\"\"\n    \"\"\" test_types_coverage\n    \n        The **test_types_coverage** a list of test types, the amount of which is 100% coverage. List of available types:\n\n        'default': The default type of test case.\n        '405': The type of test case for 405 error.\n        'params': The type of test case for parameters.\n        'elem': The type of test case for elements.\n        'generation_data': The type of test case for generation data.\n        'health': The type of test case for health.\n        'env': The type of test case for environment.\n        \n    \"\"\"\n        \"\"\" test_types_exception\n    \n        The **test_types_exception** contains a list of test types that are an exception. Applying this type of test to \n        an endpoint automatically counts as 100% coverage.\n        \n    \"\"\"\n```\n\nThe project must have a test that displays information about the coverage in allure. The name of it **test_zorro.py**:\n\n```commandline\nimport allure\nimport pytest\n\nfrom partest.zorro_report import zorro\n\n@pytest.mark.asyncio\nclass TestCoverAge:\n\n    async def test_display_final_call_counts(self):\n        zorro()\n        assert True\n\n```\n\nWhat does the test look like:\n\n```commandline\n    async def test_get(self, api_client):\n        endpoint = 'https://ya.ru'\n        response = await api_client.make_request(\n            'GET',\n            endpoint,\n            params='limit=1',\n            expected_status_code=200,\n            validate_model=Models.ValidateGet,\n            type=types.type_default\n        )\n        assert response is not None\n        assert isinstance(response, dict)\n```\n\nAll available data that the client can accept:\n```\n        Parameters\n        ----------\n        :param method: HTTP method to use.\n        :param endpoint: The endpoint to make the request to.\n        :param add_url1: Additional URL part 1.\n        :param add_url2: Additional URL part 2.\n        :param add_url3: Additional URL part 3.\n        :param after_url: Additional URL part after the endpoint.\n        :param defining_url: Defining URL.\n        :param params: Query parameters.\n        :param headers: Request headers.\n        :param data: Request data.\n        :param data_type: Request data type.\n        :param files: Request files.\n        :param expected_status_code: Expected status code.\n        :param validate_model: Model to validate the response.\n        :param type: Request type.\n```\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "This is a module for the rapid implementation of test cases with coverage tracking. This module contains a call counter for specific endpoints and their methods. As well as the function of determining the types of tests that need to be counted.",
    "version": "0.2.0",
    "project_urls": {
        "Homepage": "https://github.com/Dec01/partest",
        "Source": "https://github.com/Dec01/partest"
    },
    "split_keywords": [
        "autotest",
        "partest",
        "test",
        "coverage"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "63ec15249af1938ec41e4fa291678bb7f01a7737f204fb66f3d3bcf0cf4085fe",
                "md5": "fb7708464f18a724f3ca133d86a039b0",
                "sha256": "60df4d05099137ee4084d63715509ebf6ddd7f69c7516037761841fb1616dac5"
            },
            "downloads": -1,
            "filename": "partest-0.2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "fb7708464f18a724f3ca133d86a039b0",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 18780,
            "upload_time": "2025-01-12T10:26:38",
            "upload_time_iso_8601": "2025-01-12T10:26:38.210605Z",
            "url": "https://files.pythonhosted.org/packages/63/ec/15249af1938ec41e4fa291678bb7f01a7737f204fb66f3d3bcf0cf4085fe/partest-0.2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "dd1286d54350c45480b9280722246a64acdb1472a80f83a4398c14c7dd568a9b",
                "md5": "71319f4a5ad6b14b6a6225256d756057",
                "sha256": "13c5bb3238a5954f012d77451cc8575df6eba26156bc1e9198e45fb53e48b87d"
            },
            "downloads": -1,
            "filename": "partest-0.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "71319f4a5ad6b14b6a6225256d756057",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 18302,
            "upload_time": "2025-01-12T10:26:40",
            "upload_time_iso_8601": "2025-01-12T10:26:40.874109Z",
            "url": "https://files.pythonhosted.org/packages/dd/12/86d54350c45480b9280722246a64acdb1472a80f83a4398c14c7dd568a9b/partest-0.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-01-12 10:26:40",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Dec01",
    "github_project": "partest",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "attrs",
            "specs": [
                [
                    "==",
                    "23.2.0"
                ]
            ]
        },
        {
            "name": "certifi",
            "specs": [
                [
                    "==",
                    "2024.7.4"
                ]
            ]
        },
        {
            "name": "charset-normalizer",
            "specs": [
                [
                    "==",
                    "2.0.12"
                ]
            ]
        },
        {
            "name": "Faker",
            "specs": [
                [
                    ">=",
                    "13.12.0"
                ]
            ]
        },
        {
            "name": "idna",
            "specs": [
                [
                    "==",
                    "3.3"
                ]
            ]
        },
        {
            "name": "iniconfig",
            "specs": [
                [
                    "==",
                    "1.1.1"
                ]
            ]
        },
        {
            "name": "jsonschema",
            "specs": [
                [
                    "==",
                    "4.22.0"
                ]
            ]
        },
        {
            "name": "packaging",
            "specs": [
                [
                    "==",
                    "21.3"
                ]
            ]
        },
        {
            "name": "pluggy",
            "specs": [
                [
                    "==",
                    "1.5.0"
                ]
            ]
        },
        {
            "name": "py",
            "specs": [
                [
                    "==",
                    "1.11.0"
                ]
            ]
        },
        {
            "name": "pyparsing",
            "specs": [
                [
                    "==",
                    "3.0.9"
                ]
            ]
        },
        {
            "name": "pyrsistent",
            "specs": [
                [
                    "==",
                    "0.18.1"
                ]
            ]
        },
        {
            "name": "pytest",
            "specs": [
                [
                    "==",
                    "8.3.3"
                ]
            ]
        },
        {
            "name": "python-dateutil",
            "specs": [
                [
                    "==",
                    "2.8.2"
                ]
            ]
        },
        {
            "name": "requests",
            "specs": [
                [
                    "==",
                    "2.32.0"
                ]
            ]
        },
        {
            "name": "six",
            "specs": [
                [
                    "==",
                    "1.16.0"
                ]
            ]
        },
        {
            "name": "tomli",
            "specs": [
                [
                    "==",
                    "2.0.1"
                ]
            ]
        },
        {
            "name": "urllib3",
            "specs": [
                [
                    "==",
                    "2.2.2"
                ]
            ]
        },
        {
            "name": "pytest-repeat",
            "specs": [
                [
                    "==",
                    "0.9.1"
                ]
            ]
        },
        {
            "name": "pytest-asyncio",
            "specs": [
                [
                    ">=",
                    "0.23.7"
                ]
            ]
        },
        {
            "name": "pydantic",
            "specs": [
                [
                    "==",
                    "2.7.1"
                ]
            ]
        },
        {
            "name": "pytest-rerunfailures",
            "specs": [
                [
                    "~=",
                    "14.0"
                ]
            ]
        },
        {
            "name": "ruff",
            "specs": [
                [
                    "==",
                    "0.4.2"
                ]
            ]
        },
        {
            "name": "allure-pytest",
            "specs": [
                [
                    ">=",
                    "2.8.18"
                ]
            ]
        },
        {
            "name": "allure-python-commons",
            "specs": [
                [
                    "~=",
                    "2.13.5"
                ]
            ]
        },
        {
            "name": "httpx",
            "specs": [
                [
                    "~=",
                    "0.27.2"
                ]
            ]
        },
        {
            "name": "swagger-parser",
            "specs": [
                [
                    ">=",
                    "1.0.2"
                ]
            ]
        },
        {
            "name": "matplotlib",
            "specs": [
                [
                    ">=",
                    "3.9.2"
                ]
            ]
        },
        {
            "name": "pyyaml",
            "specs": [
                [
                    ">=",
                    "6.0.2"
                ]
            ]
        }
    ],
    "lcname": "partest"
}
        
Elapsed time: 0.58728s