Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12", "3.13" ]
python-version: [ "3.9", "3.10", "3.11", "3.12", "3.13" ]

steps:
- uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion ruff.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
line-length = 120
target-version = "py38"
target-version = "py39"
exclude = [".git", ".pytest_cache", ".idea", ".github", "build"]

[lint]
Expand Down
6 changes: 0 additions & 6 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,8 +1,2 @@
[flake8]
max-line-length = 120
count = True
extend-ignore = E203
exclude = __version__.py

[coverage:run]
omit = testrail_api/__version__.py
3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
use_scm_version={"write_to": "testrail_api/__version__.py"},
setup_requires=["setuptools_scm"],
install_requires=["requests>=2.32.3"],
python_requires=">=3.8",
python_requires=">=3.9",
include_package_data=True,
keywords=[
"testrail",
Expand All @@ -39,7 +39,6 @@
"Natural Language :: English",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
Expand Down
208 changes: 106 additions & 102 deletions testrail_api/_category.py

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions testrail_api/_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from json.decoder import JSONDecodeError
from os import environ
from pathlib import Path
from typing import Any, Callable, Dict, Optional, Tuple, Type, Union
from typing import Any, Callable, Final, Optional, Union

import requests

Expand All @@ -17,7 +17,7 @@

logger = logging.getLogger(__package__)

RATE_LIMIT_STATUS_CODE = 429
RATE_LIMIT_STATUS_CODE: Final[int] = 429


class Environ:
Expand All @@ -40,7 +40,7 @@ def __init__( # noqa: PLR0913
exc: bool = False,
rate_limit: bool = True,
warn_ignore: bool = False,
retry_exceptions: Tuple[Type[BaseException], ...] = (),
retry_exceptions: tuple[type[BaseException], ...] = (),
response_handler: Optional[Callable[[requests.Response], Any]] = None,
session: Optional[requests.Session] = None,
**kwargs,
Expand All @@ -55,7 +55,7 @@ def __init__( # noqa: PLR0913
:param password:
Password for the account on the TestRail or token.
:param session:
Given session will be used instead of new one.
A Given session will be used instead of new one.
:param exc:
Catching exceptions.
:param rate_limit:
Expand Down Expand Up @@ -183,7 +183,7 @@ def __post_converter(json: dict) -> None:
# Converting a datetime value to integer (UNIX timestamp)
json[key] = round(value.timestamp())

def get(self, endpoint: str, params: Optional[Dict[Any, Any]] = None) -> Any:
def get(self, endpoint: str, params: Optional[dict[Any, Any]] = None) -> Any:
"""GET method."""
return self.request(
method=METHODS.GET,
Expand All @@ -194,8 +194,8 @@ def get(self, endpoint: str, params: Optional[Dict[Any, Any]] = None) -> Any:
def post(
self,
endpoint: str,
params: Optional[Dict[Any, Any]] = None,
json: Optional[Dict[Any, Any]] = None,
params: Optional[dict[Any, Any]] = None,
json: Optional[dict[Any, Any]] = None,
) -> Any:
"""POST method."""
return self.request(
Expand Down
240 changes: 24 additions & 216 deletions testrail_api/_testrail_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,219 +7,27 @@
class TestRailAPI(Session):
"""API Categories."""

@property
def attachments(self) -> _category.Attachments:
"""
Use the following API methods to upload, retrieve and delete attachments.

https://www.gurock.com/testrail/docs/api/reference/attachments
"""
return _category.Attachments(self)

@property
def cases(self) -> _category.Cases:
"""
Use the following API methods to request details about test cases and to create or modify test cases.

https://www.gurock.com/testrail/docs/api/reference/cases
"""
return _category.Cases(self)

@property
def case_fields(self) -> _category.CaseFields:
"""
Use the following API methods to request details about custom fields for test cases.

https://www.gurock.com/testrail/docs/api/reference/case-fields
"""
return _category.CaseFields(self)

@property
def case_types(self) -> _category.CaseTypes:
"""
Use the following API methods to request details about case type.

https://www.gurock.com/testrail/docs/api/reference/case-types
"""
return _category.CaseTypes(self)

@property
def configurations(self) -> _category.Configurations:
"""
Use the following API methods to request details about configurations and to create or modify configurations.

https://www.gurock.com/testrail/docs/api/reference/configurations
"""
return _category.Configurations(self)

@property
def milestones(self) -> _category.Milestones:
"""
Use the following API methods to request details about milestones and to create or modify milestones.

https://www.gurock.com/testrail/docs/api/reference/milestones
"""
return _category.Milestones(self)

@property
def plans(self) -> _category.Plans:
"""
Use the following API methods to request details about test plans and to create or modify test plans.

https://www.gurock.com/testrail/docs/api/reference/plans
"""
return _category.Plans(self)

@property
def priorities(self) -> _category.Priorities:
"""
Use the following API methods to request details about priorities.

https://www.gurock.com/testrail/docs/api/reference/priorities
"""
return _category.Priorities(self)

@property
def projects(self) -> _category.Projects:
"""
Use the following API methods to request details about projects and to create or modify projects.

https://www.gurock.com/testrail/docs/api/reference/projects
"""
return _category.Projects(self)

@property
def reports(self) -> _category.Reports:
"""
Use the following methods to get and run reports that have been made accessible to the API.

https://www.gurock.com/testrail/docs/api/reference/reports
"""
return _category.Reports(self)

@property
def results(self) -> _category.Results:
"""
Use the following API methods to request details about test results and to add new test results.

https://www.gurock.com/testrail/docs/api/reference/results
"""
return _category.Results(self)

@property
def result_fields(self) -> _category.ResultFields:
"""
Use the following API methods to request details about custom fields for test results.

https://www.gurock.com/testrail/docs/api/reference/result-fields
"""
return _category.ResultFields(self)

@property
def runs(self) -> _category.Runs:
"""
Use the following API methods to request details about test runs and to create or modify test runs.

https://www.gurock.com/testrail/docs/api/reference/runs
"""
return _category.Runs(self)

@property
def sections(self) -> _category.Sections:
"""
Use the following API methods to request details about sections and to create or modify sections.

Sections are used to group and organize test cases in test suites.
https://www.gurock.com/testrail/docs/api/reference/sections
"""
return _category.Sections(self)

@property
def shared_steps(self) -> _category.SharedSteps:
"""
Use the following API methods to request details about shared steps.

https://www.gurock.com/testrail/docs/api/reference/api-shared-steps
"""
return _category.SharedSteps(self)

@property
def statuses(self) -> _category.Statuses:
"""
Use the following API methods to request details about test statuses.

https://www.gurock.com/testrail/docs/api/reference/statuses
"""
return _category.Statuses(self)

@property
def suites(self) -> _category.Suites:
"""
Use the following API methods to request details about test suites and to create or modify test suites.

https://www.gurock.com/testrail/docs/api/reference/suites
"""
return _category.Suites(self)

@property
def templates(self) -> _category.Template:
"""
Use the following API methods to request details about templates (field layouts for cases/results).

https://www.gurock.com/testrail/docs/api/reference/templates
"""
return _category.Template(self)

@property
def tests(self) -> _category.Tests:
"""
Use the following API methods to request details about tests.

https://www.gurock.com/testrail/docs/api/reference/tests
"""
return _category.Tests(self)

@property
def users(self) -> _category.Users:
"""
Use the following API methods to request details about users.

https://www.gurock.com/testrail/docs/api/reference/users
"""
return _category.Users(self)

@property
def roles(self) -> _category.Roles:
"""
Use the following API methods to request details about roles.

https://support.testrail.com/hc/en-us/articles/7077853258772-Roles
"""
return _category.Roles(self)

@property
def groups(self) -> _category.Groups:
"""
Use the following API methods to request details about groups.

https://support.testrail.com/hc/en-us/articles/7077338821012-Groups
"""
return _category.Groups(self)

@property
def variables(self) -> _category.Variables:
"""
Use the following API methods to upload, retrieve, update, and delete variables that exist in datasets.

https://support.testrail.com/hc/en-us/articles/7077979742868-Variables
"""
return _category.Variables(self)

@property
def datasets(self) -> _category.Datasets:
"""
Use the following API methods to upload, retrieve, update, and delete datasets.

https://support.testrail.com/hc/en-us/articles/7077300491540-Datasets
"""
return _category.Datasets(self)
attachments: _category.Attachments = _category.Attachments()
cases: _category.Cases = _category.Cases()
case_fields: _category.CaseFields = _category.CaseFields()
case_types: _category.CaseTypes = _category.CaseTypes()
configurations: _category.Configurations = _category.Configurations()
milestones: _category.Milestones = _category.Milestones()
plans: _category.Plans = _category.Plans()
priorities: _category.Priorities = _category.Priorities()
projects: _category.Projects = _category.Projects()
reports: _category.Reports = _category.Reports()
results: _category.Results = _category.Results()
result_fields: _category.ResultFields = _category.ResultFields()
runs: _category.Runs = _category.Runs()
sections: _category.Sections = _category.Sections()
shared_steps: _category.SharedSteps = _category.SharedSteps()
statuses: _category.Statuses = _category.Statuses()
suites: _category.Suites = _category.Suites()
templates: _category.Template = _category.Template()
tests: _category.Tests = _category.Tests()
users: _category.Users = _category.Users()
roles: _category.Roles = _category.Roles()
groups: _category.Groups = _category.Groups()
variables: _category.Variables = _category.Variables()
datasets: _category.Datasets = _category.Datasets()
9 changes: 5 additions & 4 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
from collections.abc import Iterator
from pathlib import Path
from typing import Callable, Iterator, Tuple
from typing import Callable

import pytest
import responses
Expand Down Expand Up @@ -72,7 +73,7 @@ def base_path() -> str:


@pytest.fixture(scope="session")
def auth_data(host: str) -> Tuple[str, str, str]:
def auth_data(host: str) -> tuple[str, str, str]:
"""Test data for authorization."""
return host, "[email protected]", "password"

Expand All @@ -85,13 +86,13 @@ def mock() -> Iterator[RequestsMock]:


@pytest.fixture
def api(auth_data: Tuple[str, str, str]) -> TestRailAPI:
def api(auth_data: tuple[str, str, str]) -> TestRailAPI:
"""TestRailAPI object."""
return TestRailAPI(*auth_data)


@pytest.fixture
def environ(auth_data: Tuple[str, str, str]) -> Iterator[None]:
def environ(auth_data: tuple[str, str, str]) -> Iterator[None]:
"""Set envs."""
os.environ["TESTRAIL_URL"] = auth_data[0]
os.environ["TESTRAIL_EMAIL"] = auth_data[1]
Expand Down
Loading