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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file partest-0.2.14.tar.gz.
File metadata
- Download URL: partest-0.2.14.tar.gz
- Upload date:
- Size: 19.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5d5584b8a6af740621d1f07cf9f5ac2b6d02a7f6c9764ba28d56a3d73bac9ca8
|
|
| MD5 |
bccdd6f6219d100afb31da50a75f756a
|
|
| BLAKE2b-256 |
2c60e43b894482273a9dc757250a9581595a4dc4362ba251265162a5c1104ca3
|
File details
Details for the file partest-0.2.14-py3-none-any.whl.
File metadata
- Download URL: partest-0.2.14-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5f665329057d6a785e0c6b52cb906a3125a673d66c350aa99691dddd08304cf0
|
|
| MD5 |
8f95d5a711def72685fa2f92a6a969b9
|
|
| BLAKE2b-256 |
d640fe815a25f70ee6d364a78479271918d6833f5253baa1133d7772e1232ef8
|