diff options
| author | Nejc Habjan <nejc.habjan@siemens.com> | 2022-10-22 14:48:48 +0200 |
|---|---|---|
| committer | John Villalovos <john@sodarock.com> | 2022-10-27 08:06:52 -0700 |
| commit | ee143c9d6df0f1498483236cc228e12132bef132 (patch) | |
| tree | a549d5e1f837420e8f58ec73c5fa3800b1163a1b | |
| parent | 50731c173083460f249b1718cbe2288fc3c46c1a (diff) | |
| download | gitlab-ee143c9d6df0f1498483236cc228e12132bef132.tar.gz | |
chore: add basic typing to functional tests
| -rw-r--r-- | pyproject.toml | 2 | ||||
| -rw-r--r-- | requirements-lint.txt | 1 | ||||
| -rw-r--r-- | tests/functional/conftest.py | 7 | ||||
| -rw-r--r-- | tests/functional/helpers.py | 8 |
4 files changed, 11 insertions, 7 deletions
diff --git a/pyproject.toml b/pyproject.toml index 15b897d..8e2bf2d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,7 +12,6 @@ strict = true module = [ "docs.*", "docs.ext.*", - "tests.functional.*", "tests.functional.api.*", "tests.unit.*", ] @@ -20,6 +19,7 @@ ignore_errors = true [[tool.mypy.overrides]] module = [ + "tests.functional.*", "tests.meta.*", "tests.smoke.*", ] diff --git a/requirements-lint.txt b/requirements-lint.txt index 5aa4e35..1ea9dfa 100644 --- a/requirements-lint.txt +++ b/requirements-lint.txt @@ -6,6 +6,7 @@ isort==5.10.1 mypy==0.981 pylint==2.15.3 pytest==7.1.3 +responses==0.21.0 types-PyYAML==6.0.12 types-requests==2.28.11.2 types-setuptools==65.5.0.1 diff --git a/tests/functional/conftest.py b/tests/functional/conftest.py index 343b608..3700ae6 100644 --- a/tests/functional/conftest.py +++ b/tests/functional/conftest.py @@ -37,7 +37,7 @@ def gitlab_version(gl) -> GitlabVersion: @pytest.fixture(scope="session") -def fixture_dir(test_dir) -> pathlib.Path: +def fixture_dir(test_dir: pathlib.Path) -> pathlib.Path: return test_dir / "functional" / "fixtures" @@ -56,7 +56,8 @@ def gitlab_container_name() -> str: @pytest.fixture(scope="session") def gitlab_docker_port(docker_services, gitlab_service_name: str) -> int: - return docker_services.port_for(service=gitlab_service_name, container_port=80) + port: int = docker_services.port_for(gitlab_service_name, container_port=80) + return port @pytest.fixture(scope="session") @@ -114,7 +115,7 @@ def reset_gitlab(gl: gitlab.Gitlab) -> None: helpers.safe_delete(user, hard_delete=True) -def set_token(container, fixture_dir): +def set_token(container: str, fixture_dir: pathlib.Path) -> str: logging.info("Creating API token.") set_token_rb = fixture_dir / "set_token.rb" diff --git a/tests/functional/helpers.py b/tests/functional/helpers.py index 840b71f..029b482 100644 --- a/tests/functional/helpers.py +++ b/tests/functional/helpers.py @@ -1,6 +1,6 @@ import logging import time -from typing import Optional +from typing import Optional, TYPE_CHECKING import pytest @@ -19,8 +19,10 @@ def get_gitlab_plan(gl: gitlab.Gitlab) -> Optional[str]: license = gl.get_license() except gitlab.exceptions.GitlabLicenseError: # Without a license we assume only Free features are available - return + return None + if TYPE_CHECKING: + assert isinstance(license["plan"], str) return license["plan"] @@ -34,7 +36,7 @@ def safe_delete( manager = object.manager for index in range(MAX_ITERATIONS): try: - object = manager.get(object.get_id()) + object = manager.get(object.get_id()) # type: ignore[attr-defined] except gitlab.exceptions.GitlabGetError: return |
