Skip to content

Commit 304dfe5

Browse files
committed
Fix unit tests
1 parent 488f275 commit 304dfe5

File tree

4 files changed

+5
-24
lines changed

4 files changed

+5
-24
lines changed

infrahub_sdk/ctl/check.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ async def run_check(
8888
format_json: bool,
8989
path: str,
9090
repository_config: InfrahubRepositoryConfig,
91-
branch: Optional[str] = None,
91+
branch: str | None = None,
9292
params: dict | None = None,
9393
) -> bool:
9494
module_name = check_module.name
@@ -135,7 +135,7 @@ async def run_targeted_check(
135135
path: str,
136136
repository_config: InfrahubRepositoryConfig,
137137
variables: dict[str, str],
138-
branch: Optional[str] = None,
138+
branch: str | None = None,
139139
) -> bool:
140140
filters = {}
141141
param_value = list(check_module.definition.parameters.values())
@@ -187,7 +187,7 @@ async def run_checks(
187187
path: str,
188188
variables: dict[str, str],
189189
repository_config: InfrahubRepositoryConfig,
190-
branch: Optional[str] = None,
190+
branch: str | None = None,
191191
) -> None:
192192
log = logging.getLogger("infrahub")
193193

tests/unit/ctl/test_cli.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
1-
import sys
21

3-
import pytest
42
from typer.testing import CliRunner
53

64
from infrahub_sdk.ctl.cli import app
75

86
runner = CliRunner()
97

10-
requires_python_310 = pytest.mark.skipif(sys.version_info < (3, 10), reason="Requires Python 3.10 or higher")
11-
128

139
def test_main_app():
1410
result = runner.invoke(app, ["--help"])

tests/unit/ctl/test_repository_app.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
"""Integration tests for infrahubctl commands."""
22

3-
import sys
43
from unittest import mock
54

65
import pytest
@@ -13,8 +12,6 @@
1312

1413
runner = CliRunner()
1514

16-
requires_python_310 = pytest.mark.skipif(sys.version_info < (3, 10), reason="Requires Python 3.10 or higher")
17-
1815

1916
@pytest.fixture
2017
def mock_client() -> mock.Mock:
@@ -29,7 +26,6 @@ def mock_client() -> mock.Mock:
2926
class TestInfrahubctlRepository:
3027
"""Groups the 'infrahubctl repository' test cases."""
3128

32-
@requires_python_310
3329
@mock.patch("infrahub_sdk.ctl.repository.initialize_client")
3430
def test_repo_no_username_or_password(self, mock_init_client, mock_client) -> None:
3531
"""Case allow no username to be passed in and set it as None rather than blank string that fails."""
@@ -78,7 +74,6 @@ def test_repo_no_username_or_password(self, mock_init_client, mock_client) -> No
7874
tracker="mutation-repository-create",
7975
)
8076

81-
@requires_python_310
8277
@mock.patch("infrahub_sdk.ctl.repository.initialize_client")
8378
def test_repo_no_username(self, mock_init_client, mock_client) -> None:
8479
"""Case allow no username to be passed in and set it as None rather than blank string that fails."""
@@ -139,7 +134,6 @@ def test_repo_no_username(self, mock_init_client, mock_client) -> None:
139134
tracker="mutation-repository-create",
140135
)
141136

142-
@requires_python_310
143137
@mock.patch("infrahub_sdk.ctl.repository.initialize_client")
144138
def test_repo_username(self, mock_init_client, mock_client) -> None:
145139
"""Case allow no username to be passed in and set it as None rather than blank string that fails."""
@@ -202,7 +196,6 @@ def test_repo_username(self, mock_init_client, mock_client) -> None:
202196
tracker="mutation-repository-create",
203197
)
204198

205-
@requires_python_310
206199
@mock.patch("infrahub_sdk.ctl.repository.initialize_client")
207200
def test_repo_readonly_true(self, mock_init_client, mock_client) -> None:
208201
"""Case allow no username to be passed in and set it as None rather than blank string that fails."""
@@ -264,7 +257,6 @@ def test_repo_readonly_true(self, mock_init_client, mock_client) -> None:
264257
tracker="mutation-repository-create",
265258
)
266259

267-
@requires_python_310
268260
@mock.patch("infrahub_sdk.ctl.repository.initialize_client")
269261
def test_repo_description_commit_branch(self, mock_init_client, mock_client) -> None:
270262
"""Case allow no username to be passed in and set it as None rather than blank string that fails."""
@@ -333,9 +325,8 @@ def test_repo_description_commit_branch(self, mock_init_client, mock_client) ->
333325
tracker="mutation-repository-create",
334326
)
335327

336-
@requires_python_310
337-
@mock.patch("infrahub_sdk.ctl.repository.initialize_client")
328+
# @mock.patch("infrahub_sdk.ctl.repository.initialize_client")
338329
def test_repo_list(self, mock_repositories_list) -> None:
339330
result = runner.invoke(app, ["repository", "list", "--branch", "main"])
340-
assert result.exit_code == 0
341331
assert strip_color(result.stdout) == read_fixture("output.txt", "integration/test_infrahubctl/repository_list")
332+
assert result.exit_code == 0

tests/unit/ctl/test_validate_app.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import sys
21

32
import pytest
43
from typer.testing import CliRunner
@@ -9,10 +8,7 @@
98

109
runner = CliRunner()
1110

12-
requires_python_310 = pytest.mark.skipif(sys.version_info < (3, 10), reason="Requires Python 3.10 or higher")
1311

14-
15-
@requires_python_310
1612
def test_validate_schema_valid():
1713
fixture_file = get_fixtures_dir() / "models" / "valid_model_01.json"
1814

@@ -21,7 +17,6 @@ def test_validate_schema_valid():
2117
assert "Schema is valid" in result.stdout
2218

2319

24-
@requires_python_310
2520
def test_validate_schema_empty():
2621
fixture_file = get_fixtures_dir() / "models" / "empty.json"
2722

@@ -30,7 +25,6 @@ def test_validate_schema_empty():
3025
assert "Empty YAML/JSON file" in remove_ansi_color(result.stdout)
3126

3227

33-
@requires_python_310
3428
def test_validate_schema_non_valid():
3529
fixture_file = get_fixtures_dir() / "models" / "non_valid_model_01.json"
3630

0 commit comments

Comments
 (0)