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: 2 additions & 0 deletions tests/unit/auth/test_k8s.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""Unit tests for auth/k8s module."""

# pylint: disable=too-many-arguments,too-many-positional-arguments,too-few-public-methods,protected-access

import os

import pytest
Expand Down
12 changes: 7 additions & 5 deletions tests/unit/utils/test_checks.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
import os
import pytest
"""Unit tests for functions defined in utils/checks module."""

import os
from unittest.mock import patch

import pytest

from utils import checks


@pytest.fixture
def input_file(tmp_path):
@pytest.fixture(name="input_file")
def input_file_fixture(tmp_path):
"""Create file manually using the tmp_path fixture."""
filename = os.path.join(tmp_path, "mydoc.csv")
with open(filename, "wt") as fout:
with open(filename, "wt", encoding="utf-8") as fout:
fout.write("some content!")
return filename

Expand Down
3 changes: 2 additions & 1 deletion tests/unit/utils/test_common.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
"""Test module for utils/common.py."""

import pytest
from unittest.mock import Mock, AsyncMock
from logging import Logger

import pytest

from utils.common import (
retrieve_user_id,
register_mcp_servers_async,
Expand Down
4 changes: 4 additions & 0 deletions tests/unit/utils/test_suid.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
"""Unit tests for functions defined in utils.suid module."""

from utils import suid


class TestSUID:
"""Unit tests for functions defined in utils.suid module."""

def test_get_suid(self):
"""Test that get_suid generates a valid UUID."""
suid_value = suid.get_suid()
Expand Down
10 changes: 6 additions & 4 deletions tests/unit/utils/test_types.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
"""Test module for utils/types.py."""
"""Unit tests for functionns defined in utils/types.py."""

from unittest.mock import Mock

from utils.types import GraniteToolParser


class TestGraniteToolParser:
"""Unit tests for functionns defined in utils/types.py."""

def test_get_tool_parser_when_model_is_is_not_granite(self):
"""Test that the tool_parser is None when model_id is not a granite model."""
assert (
Expand All @@ -29,12 +31,12 @@ def test_get_tool_calls_from_completion_message_when_none(self):
assert tool_parser.get_tool_calls(None) == [], "get_tool_calls should return []"

def test_get_tool_calls_from_completion_message_when_not_none(self):
"""Test that get_tool_calls returns an empty array when CompletionMessage has no tool_calls."""
"""Test that get_tool_calls returns an empty array when CompletionMessage has no tool_calls.""" # pylint: disable=line-too-long
tool_parser = GraniteToolParser.get_parser("granite-3.3-8b-instruct")
completion_message = Mock()
completion_message.tool_calls = []
assert (
tool_parser.get_tool_calls(completion_message) == []
assert not tool_parser.get_tool_calls(
completion_message
), "get_tool_calls should return []"
Comment on lines +38 to 40
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Assertion became too permissive

assert not tool_parser.get_tool_calls(... ) passes for [], None, False, or any falsy value, whereas the previous equality check guaranteed an empty list.
To keep the test strict and reduce false negatives, revert to explicit list comparison:

-assert not tool_parser.get_tool_calls(completion_message)
+assert tool_parser.get_tool_calls(completion_message) == []

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In tests/unit/utils/test_types.py around lines 38 to 40, the assertion uses
'assert not' which passes for any falsy value, not just an empty list. Change
the assertion back to explicitly compare the result of
tool_parser.get_tool_calls(completion_message) to an empty list using '== []' to
ensure the test strictly checks for an empty list.


def test_get_tool_calls_from_completion_message_when_message_has_tool_calls(self):
Expand Down