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
3 changes: 0 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -343,9 +343,6 @@ max-complexity = 17
"tests/unit/sdk/test_store.py" = ["ANN001"] # 12 errors
"tests/unit/sdk/spec/test_object.py" = ["ANN001"] # 11 errors
"tests/unit/sdk/conftest.py" = ["ANN001"] # 11 errors
"tests/unit/sdk/test_diff_summary.py" = ["ANN001"] # 9 errors
"tests/unit/sdk/test_object_store.py" = ["ANN001"] # 7 errors
"tests/unit/sdk/graphql/test_query.py" = ["ANN001"] # 7 errors

# tests/integration/
"tests/integration/test_infrahub_client.py" = ["PLR0904"]
Expand Down
15 changes: 8 additions & 7 deletions tests/unit/sdk/graphql/test_query.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from enum import Enum
from typing import Any

from infrahub_sdk.graphql.query import Mutation, Query

Expand All @@ -13,7 +14,7 @@ class MyIntEnum(int, Enum):
VALUE2 = 24


def test_query_rendering_no_vars(query_data_no_filter) -> None:
def test_query_rendering_no_vars(query_data_no_filter: dict[str, Any]) -> None:
query = Query(query=query_data_no_filter)

expected_query = """
Expand All @@ -37,7 +38,7 @@ def test_query_rendering_no_vars(query_data_no_filter) -> None:
assert query.render() == expected_query


def test_query_rendering_empty_filter(query_data_empty_filter) -> None:
def test_query_rendering_empty_filter(query_data_empty_filter: dict[str, Any]) -> None:
query = Query(query=query_data_empty_filter)

expected_query = """
Expand All @@ -61,7 +62,7 @@ def test_query_rendering_empty_filter(query_data_empty_filter) -> None:
assert query.render() == expected_query


def test_query_rendering_with_filters_and_vars(query_data_filters_01) -> None:
def test_query_rendering_with_filters_and_vars(query_data_filters_01: dict[str, Any]) -> None:
query = Query(query=query_data_filters_01, variables={"name": str, "enabled": bool})

expected_query = """
Expand All @@ -85,7 +86,7 @@ def test_query_rendering_with_filters_and_vars(query_data_filters_01) -> None:
assert query.render() == expected_query


def test_query_rendering_with_filters(query_data_filters_02) -> None:
def test_query_rendering_with_filters(query_data_filters_02: dict[str, Any]) -> None:
query = Query(query=query_data_filters_02)

expected_query = """
Expand All @@ -105,7 +106,7 @@ def test_query_rendering_with_filters(query_data_filters_02) -> None:
assert query.render() == expected_query


def test_query_rendering_with_filters_convert_enum(query_data_filters_02) -> None:
def test_query_rendering_with_filters_convert_enum(query_data_filters_02: dict[str, Any]) -> None:
query = Query(query=query_data_filters_02)

expected_query = """
Expand All @@ -125,7 +126,7 @@ def test_query_rendering_with_filters_convert_enum(query_data_filters_02) -> Non
assert query.render(convert_enum=True) == expected_query


def test_mutation_rendering_no_vars(input_data_01) -> None:
def test_mutation_rendering_no_vars(input_data_01: dict[str, Any]) -> None:
query_data = {"ok": None, "object": {"id": None}}

query = Mutation(mutation="myobject_create", query=query_data, input_data=input_data_01)
Expand Down Expand Up @@ -245,7 +246,7 @@ def test_mutation_rendering_enum() -> None:
assert query.render() == expected_query


def test_mutation_rendering_with_vars(input_data_01) -> None:
def test_mutation_rendering_with_vars(input_data_01: dict[str, Any]) -> None:
query_data = {"ok": None, "object": {"id": None}}
variables = {"name": str, "description": str, "number": int}
query = Mutation(
Expand Down
12 changes: 7 additions & 5 deletions tests/unit/sdk/test_diff_summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ async def mock_diff_tree_query(httpx_mock: HTTPXMock, client: InfrahubClient) ->


@pytest.mark.parametrize("client_type", client_types)
async def test_diffsummary(clients: BothClients, mock_diff_tree_query, client_type) -> None:
async def test_diffsummary(clients: BothClients, mock_diff_tree_query: HTTPXMock, client_type: str) -> None:
if client_type == "standard":
node_diffs = await clients.standard.get_diff_summary(
branch="branch2",
Expand Down Expand Up @@ -241,7 +241,7 @@ async def mock_diff_tree_with_metadata(httpx_mock: HTTPXMock, client: InfrahubCl


@pytest.mark.parametrize("client_type", client_types)
async def test_get_diff_tree(clients: BothClients, mock_diff_tree_with_metadata, client_type) -> None:
async def test_get_diff_tree(clients: BothClients, mock_diff_tree_with_metadata: HTTPXMock, client_type: str) -> None:
"""Test get_diff_tree returns complete DiffTreeData with metadata."""
if client_type == "standard":
diff_tree = await clients.standard.get_diff_tree(
Expand Down Expand Up @@ -298,7 +298,7 @@ async def mock_diff_tree_none(httpx_mock: HTTPXMock, client: InfrahubClient) ->


@pytest.mark.parametrize("client_type", client_types)
async def test_get_diff_tree_none(clients: BothClients, mock_diff_tree_none, client_type) -> None:
async def test_get_diff_tree_none(clients: BothClients, mock_diff_tree_none: HTTPXMock, client_type: str) -> None:
"""Test get_diff_tree returns None when no diff exists."""
if client_type == "standard":
diff_tree = await clients.standard.get_diff_tree(
Expand Down Expand Up @@ -343,7 +343,9 @@ async def mock_diff_tree_with_params(httpx_mock: HTTPXMock, client: InfrahubClie


@pytest.mark.parametrize("client_type", client_types)
async def test_get_diff_tree_with_parameters(clients: BothClients, mock_diff_tree_with_params, client_type) -> None:
async def test_get_diff_tree_with_parameters(
clients: BothClients, mock_diff_tree_with_params: HTTPXMock, client_type: str
) -> None:
"""Test get_diff_tree with name and time range parameters."""
from_time = datetime(2025, 11, 14, 12, 0, 0, tzinfo=timezone.utc)
to_time = datetime(2025, 11, 14, 18, 0, 0, tzinfo=timezone.utc)
Expand Down Expand Up @@ -373,7 +375,7 @@ async def test_get_diff_tree_with_parameters(clients: BothClients, mock_diff_tre


@pytest.mark.parametrize("client_type", client_types)
async def test_get_diff_tree_time_validation(clients: BothClients, client_type) -> None:
async def test_get_diff_tree_time_validation(clients: BothClients, client_type: str) -> None:
"""Test get_diff_tree raises error when from_time > to_time."""
from_time = datetime(2025, 11, 14, 18, 0, 0, tzinfo=timezone.utc)
to_time = datetime(2025, 11, 14, 12, 0, 0, tzinfo=timezone.utc) # Earlier than from_time
Expand Down
9 changes: 6 additions & 3 deletions tests/unit/sdk/test_object_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from pytest_httpx import HTTPXMock

from infrahub_sdk.object_store import ObjectStore, ObjectStoreSync
from tests.unit.sdk.conftest import BothClients

async_methods = [method for method in dir(ObjectStore) if not method.startswith("_")]
sync_methods = [method for method in dir(ObjectStoreSync) if not method.startswith("_")]
Expand Down Expand Up @@ -44,7 +45,7 @@ async def test_method_sanity() -> None:


@pytest.mark.parametrize("method", async_methods)
async def test_validate_method_signature(method) -> None:
async def test_validate_method_signature(method: str) -> None:
async_method = getattr(ObjectStore, method)
sync_method = getattr(ObjectStoreSync, method)
async_sig = inspect.signature(async_method)
Expand All @@ -54,7 +55,7 @@ async def test_validate_method_signature(method) -> None:


@pytest.mark.parametrize("client_type", client_types)
async def test_object_store_get(client_type, clients, mock_get_object_store_01) -> None:
async def test_object_store_get(client_type: str, clients: BothClients, mock_get_object_store_01: HTTPXMock) -> None:
client = getattr(clients, client_type)

if client_type == "standard":
Expand All @@ -66,7 +67,9 @@ async def test_object_store_get(client_type, clients, mock_get_object_store_01)


@pytest.mark.parametrize("client_type", client_types)
async def test_object_store_upload(client_type, clients, mock_upload_object_store_01) -> None:
async def test_object_store_upload(
client_type: str, clients: BothClients, mock_upload_object_store_01: HTTPXMock
) -> None:
client = getattr(clients, client_type)

if client_type == "standard":
Expand Down