Skip to main content

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.

Project description

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:

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:

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:

    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.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

partest-0.2.10.tar.gz (19.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

partest-0.2.10-py3-none-any.whl (22.7 kB view details)

Uploaded Python 3

File details

Details for the file partest-0.2.10.tar.gz.

File metadata

  • Download URL: partest-0.2.10.tar.gz
  • Upload date:
  • Size: 19.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.11

File hashes

Hashes for partest-0.2.10.tar.gz
Algorithm Hash digest
SHA256 501f34924649a2db36c2070c5dd2f6d5f3476c66bcd79aa6e554f8e2054b664a
MD5 2431c7bb253358441d47d09a101b8121
BLAKE2b-256 4286cfde03abb27936dc26170705b66cef07e3af15000bffb4334a38e17f49a1

See more details on using hashes here.

File details

Details for the file partest-0.2.10-py3-none-any.whl.

File metadata

  • Download URL: partest-0.2.10-py3-none-any.whl
  • Upload date:
  • Size: 22.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.11

File hashes

Hashes for partest-0.2.10-py3-none-any.whl
Algorithm Hash digest
SHA256 9a6d3c8d38d85a3afebe1553a0c1db2bae9ccf0cdb368f2e70bfa048c6273a4a
MD5 2b6049b6b92a662338eb1fe18230ddf9
BLAKE2b-256 169df9fe60fa2918ab7990d79ba8fc7a697b0c70f6112025564de35ca02a119f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page