Skip to content

Commit ee143c9

Browse files
nejchJohnVillalovos
authored andcommitted
chore: add basic typing to functional tests
1 parent 50731c1 commit ee143c9

File tree

4 files changed

+11
-7
lines changed

4 files changed

+11
-7
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ strict = true
1212
module = [
1313
"docs.*",
1414
"docs.ext.*",
15-
"tests.functional.*",
1615
"tests.functional.api.*",
1716
"tests.unit.*",
1817
]
1918
ignore_errors = true
2019

2120
[[tool.mypy.overrides]]
2221
module = [
22+
"tests.functional.*",
2323
"tests.meta.*",
2424
"tests.smoke.*",
2525
]

requirements-lint.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ isort==5.10.1
66
mypy==0.981
77
pylint==2.15.3
88
pytest==7.1.3
9+
responses==0.21.0
910
types-PyYAML==6.0.12
1011
types-requests==2.28.11.2
1112
types-setuptools==65.5.0.1

tests/functional/conftest.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def gitlab_version(gl) -> GitlabVersion:
3737

3838

3939
@pytest.fixture(scope="session")
40-
def fixture_dir(test_dir) -> pathlib.Path:
40+
def fixture_dir(test_dir: pathlib.Path) -> pathlib.Path:
4141
return test_dir / "functional" / "fixtures"
4242

4343

@@ -56,7 +56,8 @@ def gitlab_container_name() -> str:
5656

5757
@pytest.fixture(scope="session")
5858
def gitlab_docker_port(docker_services, gitlab_service_name: str) -> int:
59-
return docker_services.port_for(service=gitlab_service_name, container_port=80)
59+
port: int = docker_services.port_for(gitlab_service_name, container_port=80)
60+
return port
6061

6162

6263
@pytest.fixture(scope="session")
@@ -114,7 +115,7 @@ def reset_gitlab(gl: gitlab.Gitlab) -> None:
114115
helpers.safe_delete(user, hard_delete=True)
115116

116117

117-
def set_token(container, fixture_dir):
118+
def set_token(container: str, fixture_dir: pathlib.Path) -> str:
118119
logging.info("Creating API token.")
119120
set_token_rb = fixture_dir / "set_token.rb"
120121

tests/functional/helpers.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import logging
22
import time
3-
from typing import Optional
3+
from typing import Optional, TYPE_CHECKING
44

55
import pytest
66

@@ -19,8 +19,10 @@ def get_gitlab_plan(gl: gitlab.Gitlab) -> Optional[str]:
1919
license = gl.get_license()
2020
except gitlab.exceptions.GitlabLicenseError:
2121
# Without a license we assume only Free features are available
22-
return
22+
return None
2323

24+
if TYPE_CHECKING:
25+
assert isinstance(license["plan"], str)
2426
return license["plan"]
2527

2628

@@ -34,7 +36,7 @@ def safe_delete(
3436
manager = object.manager
3537
for index in range(MAX_ITERATIONS):
3638
try:
37-
object = manager.get(object.get_id())
39+
object = manager.get(object.get_id()) # type: ignore[attr-defined]
3840
except gitlab.exceptions.GitlabGetError:
3941
return
4042

0 commit comments

Comments
 (0)