Skip to content

Commit

Permalink
Code reviewd
Browse files Browse the repository at this point in the history
  • Loading branch information
rquidute committed Nov 14, 2024
1 parent e12218c commit 18f082b
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
6 changes: 3 additions & 3 deletions app/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def block_on_serial_marker(request: pytest.FixtureRequest) -> Generator:


@contextlib.contextmanager
def use_real_sdk_container() -> SDKContainer:
def use_real_sdk_container() -> Generator:
"""Context manager to temporarily use the real SDKContainer"""
# Store the mock module
mock_module = sys.modules["test_collections.matter.sdk_tests.support.sdk_container"]
Expand All @@ -152,7 +152,7 @@ def use_real_sdk_container() -> SDKContainer:


@pytest.fixture
def real_sdk_container() -> SDKContainer:
def real_sdk_container() -> Generator:
"""Use the real SDKContainer in a test"""
with use_real_sdk_container() as real_module:
with use_real_sdk_container() as real_module: # noqa
yield real_module.SDKContainer()
3 changes: 2 additions & 1 deletion app/tests/sdk_container_mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import sys
from pathlib import Path
from typing import Any
from unittest.mock import AsyncMock, Mock

# Constants from the original module
Expand Down Expand Up @@ -67,7 +68,7 @@ class SDKContainerRetrieveExitCodeError(Exception):

# Create mock SDKContainer class
class MockSDKContainer:
def __new__(cls, *args, **kwargs) -> None:
def __new__(cls, *args: Any, **kwargs: Any) -> "MockSDKContainer":
return mock_instance


Expand Down
2 changes: 1 addition & 1 deletion cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@
"test_collections/matter/python_tests/docs/common_test_failures/",
"sdk_patch",
".devcontainer",
"test_collections/matter/sdk_tests/python_tests_info.json"
"test_collections/matter/sdk_tests/*.json"
],
"enableFiletypes": [
"shellscript"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,10 @@
from test_collections.matter.config import matter_settings

from ..exec_run_in_container import ExecResultExtended
from ..sdk_container import SDKContainer


@pytest.mark.asyncio
async def test_start(real_sdk_container) -> None: # noqa
async def test_start(real_sdk_container) -> None: # noqa
# Values to verify
docker_image = f"{matter_settings.SDK_DOCKER_IMAGE}:\
{matter_settings.SDK_DOCKER_TAG}"
Expand All @@ -55,7 +54,7 @@ async def test_start(real_sdk_container) -> None: # noqa


@pytest.mark.asyncio
async def test_not_start_when_running(real_sdk_container: SDKContainer) -> None:
async def test_not_start_when_running(real_sdk_container) -> None: # noqa
with mock.patch.object(
target=real_sdk_container, attribute="is_running", return_value=True
), mock.patch.object(
Expand All @@ -68,7 +67,7 @@ async def test_not_start_when_running(real_sdk_container: SDKContainer) -> None:


@pytest.mark.asyncio
async def test_destroy_container_running(real_sdk_container: SDKContainer) -> None:
async def test_destroy_container_running(real_sdk_container) -> None: # noqa
with mock.patch.object(
target=real_sdk_container, attribute="is_running", return_value=False
), mock.patch.object(
Expand All @@ -89,7 +88,7 @@ async def test_destroy_container_running(real_sdk_container: SDKContainer) -> No


@pytest.mark.asyncio
async def test_destroy_container_not_running(real_sdk_container: SDKContainer) -> None:
async def test_destroy_container_not_running(real_sdk_container) -> None: # noqa
with mock.patch.object(
target=container_manager, attribute="destroy"
) as mock_destroy:
Expand All @@ -100,7 +99,7 @@ async def test_destroy_container_not_running(real_sdk_container: SDKContainer) -


@pytest.mark.asyncio
async def test_destroy_container_once(real_sdk_container: SDKContainer) -> None:
async def test_destroy_container_once(real_sdk_container) -> None: # noqa
with mock.patch.object(
target=real_sdk_container, attribute="is_running", return_value=False
), mock.patch.object(
Expand All @@ -121,7 +120,7 @@ async def test_destroy_container_once(real_sdk_container: SDKContainer) -> None:
assert real_sdk_container._SDKContainer__container is None


def test_send_command_without_starting(real_sdk_container: SDKContainer) -> None:
def test_send_command_without_starting(real_sdk_container) -> None: # noqa
try:
real_sdk_container.send_command("--help", prefix="cmd-prefix")
assert False
Expand All @@ -132,7 +131,7 @@ def test_send_command_without_starting(real_sdk_container: SDKContainer) -> None


@pytest.mark.asyncio
async def test_send_command_default_prefix(real_sdk_container: SDKContainer) -> None:
async def test_send_command_default_prefix(real_sdk_container) -> None: # noqa
fake_container = make_fake_container()
cmd = "--help"
cmd_prefix = "cmd-prefix"
Expand Down Expand Up @@ -172,7 +171,7 @@ async def test_send_command_default_prefix(real_sdk_container: SDKContainer) ->


@pytest.mark.asyncio
async def test_send_command_custom_prefix(real_sdk_container: SDKContainer) -> None:
async def test_send_command_custom_prefix(real_sdk_container) -> None: # noqa
fake_container = make_fake_container()
cmd = "--help"
cmd_prefix = "cat"
Expand Down

0 comments on commit 18f082b

Please sign in to comment.