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.13.tar.gz (19.7 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.13-py3-none-any.whl (23.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: partest-0.2.13.tar.gz
  • Upload date:
  • Size: 19.7 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.13.tar.gz
Algorithm Hash digest
SHA256 b1e004b77fc4c2d6ed8d026892c59ef544c19dd5c56cf847e9a0d984ac154916
MD5 3ac369a25d027118c3615c84500febd2
BLAKE2b-256 21c61d6b62d702214049aea6b85c0b41f1463aef7b808276aeeab924dbf26bef

See more details on using hashes here.

File details

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

File metadata

  • Download URL: partest-0.2.13-py3-none-any.whl
  • Upload date:
  • Size: 23.0 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.13-py3-none-any.whl
Algorithm Hash digest
SHA256 b750db64eec74c4bdac9c31999a3f14ff3aed853d3a8b68006614e4985578c68
MD5 19a5106ee328ccefff5a0d2c73ee611d
BLAKE2b-256 072beae69c2fd53587846d48c6c3f1246e2d1e4d6cfc2825d8f99670003df4b4

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