Skip to content

Commit

Permalink
Code changed after code review
Browse files Browse the repository at this point in the history
  • Loading branch information
rquidute committed Nov 29, 2023
1 parent 2135ffd commit cee194f
Show file tree
Hide file tree
Showing 11 changed files with 30 additions and 51 deletions.
21 changes: 12 additions & 9 deletions app/chip_tool/chip_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,16 @@
"sdk_runner/specifications/chip/"
)
# Python Testing Folder
# LOCAL_PYTHON_TESTING_PATH = TEST_COLLECTION_SDK_CHECKOUT_PATH / Path(
# "python_testing/scripts/sdk"
# )
# DOCKER_PYTHON_TESTING_PATH = "/root/python_testing"
LOCAL_TEST_COLLECTIONS_PATH = "/home/ubuntu/certification-tool/backend/test_collections"
LOCAL_PYTHON_TESTING_PATH = Path(
LOCAL_TEST_COLLECTIONS_PATH + "/sdk_tests/sdk_checkout/python_testing/scripts/sdk"
)
DOCKER_PYTHON_TESTING_PATH = "/root/python_testing"

# RPC Client Running on SDK Container
LOCAL_RPC_PYTHON_TESTING_PATH = Path(
"/home/ubuntu/certification-tool/backend/test_collections/sdk_tests/support/python_testing/models/rpc_client/test_harness_client.py"
LOCAL_TEST_COLLECTIONS_PATH + "/sdk_tests/support/python_testing/models/rpc_client/"
"test_harness_client.py"
)
DOCKER_RPC_PYTHON_TESTING_PATH = "/root/python_testing/test_harness_client.py"

Expand Down Expand Up @@ -143,7 +145,6 @@ class ChipToolUnknownTestType(Exception):
class ChipToolTestType(str, Enum):
CHIP_TOOL = "chip-tool"
CHIP_APP = "chip-app"
PYTHON_TEST = "python-test"


class ChipTool(metaclass=Singleton):
Expand Down Expand Up @@ -180,6 +181,10 @@ class ChipTool(metaclass=Singleton):
"bind": DOCKER_CREDENTIALS_DEVELOPMENT_PATH,
"mode": "ro",
},
LOCAL_PYTHON_TESTING_PATH: {
"bind": DOCKER_PYTHON_TESTING_PATH,
"mode": "rw",
},
LOCAL_RPC_PYTHON_TESTING_PATH: {
"bind": DOCKER_RPC_PYTHON_TESTING_PATH,
"mode": "rw",
Expand Down Expand Up @@ -412,8 +417,6 @@ async def start_server(

async def destroy_device(self) -> None:
"""Destroy the device container."""
await self.stop_chip_tool_server()

if self.__chip_tool_container is not None:
container_manager.destroy(self.__chip_tool_container)
self.__chip_tool_container = None
Expand Down Expand Up @@ -607,7 +610,7 @@ async def run_test(

if test_type == ChipToolTestType.CHIP_TOOL:
test_path = f"{YAML_TESTS_PATH}/{test_id}.yaml"
elif test_type == ChipToolTestType.CHIP_APP:
else:
test_path = f"{YAML_TESTS_PATH}/{test_id}_Simulated.yaml"

parser_config = TestParserConfig(pics_path, self.specifications, test_options)
Expand Down
1 change: 0 additions & 1 deletion app/chip_tool/test_suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,4 +280,3 @@ async def __prompt_user_to_perform_decommission(self) -> None:
f"Received unknown prompt option for \
decommissioning step: {prompt_response.response}"
)

1 change: 0 additions & 1 deletion app/tests/chip_tool/test_chip_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -988,4 +988,3 @@ async def test_pairing_ble_thread_command_params() -> None:
# clean up:
chip_tool._ChipTool__chip_tool_container = None
settings.CHIP_TOOL_TRACE = original_trace_setting_value

11 changes: 0 additions & 11 deletions app/tests/python_tests/test_python_test_suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
from app.models.test_suite_execution import TestSuiteExecution
from app.test_engine.logger import test_engine_logger
from test_collections.sdk_tests.support.python_testing.models.test_suite import (
ChipToolPythonTestSuite,
PythonTestSuite,
SuiteType,
)
Expand Down Expand Up @@ -58,16 +57,6 @@ def test_python_test_suite_python_version() -> None:
assert suite_class.python_test_version == python_test_version


def test_automated_suite_subclass() -> None:
"""Test that for suite type automated class factory creates a subclass of
ChipToolPythonTestSuite, and that test_type is set to CHIP_TOOL"""
type = SuiteType.AUTOMATED
# Create a subclass of PythonTestSuite
suite_class: Type[PythonTestSuite] = PythonTestSuite.class_factory(
suite_type=type, name="SomeSuite", python_test_version="some_version"
)


@pytest.mark.asyncio
async def test_suite_setup_log_python_version() -> None:
"""Test that test suite python version is logged to test engine logger in setup."""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@


class PythonTest(MatterTest):
description: str

def __init__(self, **kwargs: Any) -> None:
super().__init__(**kwargs)
self.type: MatterTestType.AUTOMATED # type: ignore
self.type = MatterTestType.AUTOMATED
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ def __parse_test_case_from_class(
) from si

return PythonTest(
name=tc_desc,
name=tc_name,
description=tc_desc,
steps=tc_steps,
config=tc_config,
PICS=tc_pics,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def start(self, count: int) -> None:

def stop(self, duration: int) -> None:
self.results.put({"stop": {"duration": duration}})
self.is_finished = True
SDKPythonTestRunnerHooks.finished = True

def test_start(self, filename: str, name: str, count: int) -> None:
self.results.put(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import sys
from multiprocessing.managers import BaseManager

from matter_testing_support import MatterTestConfig, run_tests
import matter_testing_support

try:
from matter_yamltests.hooks import TestRunnerHooks
Expand All @@ -33,7 +33,7 @@ class TestRunnerHooks:

# Pre-computed param list for each Python Test as defined in Verification Steps.
test_params = {
"TC_ACE_1_3": MatterTestConfig(
"TC_ACE_1_3": matter_testing_support.MatterTestConfig(
tests=["test_TC_ACE_1_3"],
commissioning_method="on-network",
discriminators=[3840],
Expand All @@ -46,6 +46,8 @@ class TestRunnerHooks:


def main():

Check failure on line 48 in test_collections/sdk_tests/support/python_testing/models/rpc_client/test_harness_client.py

View workflow job for this annotation

GitHub Actions / Mypy

test_collections/sdk_tests/support/python_testing/models/rpc_client/test_harness_client.py#L48

Function is missing a return type annotation [no-untyped-def]
sys.path.append("/root/python_testing")

if len(sys.argv) != 2:
raise Exception("Python test id should be provided as the only parameter.")

Expand All @@ -64,7 +66,7 @@ def main():
manager.connect()
test_runner_hooks = manager.TestRunnerHooks() # shared object proxy

Check failure on line 67 in test_collections/sdk_tests/support/python_testing/models/rpc_client/test_harness_client.py

View workflow job for this annotation

GitHub Actions / Mypy

test_collections/sdk_tests/support/python_testing/models/rpc_client/test_harness_client.py#L67

"BaseManager" has no attribute "TestRunnerHooks" [attr-defined]

run_tests(TestClassReference, config, test_runner_hooks)
matter_testing_support.run_tests(TestClassReference, config, test_runner_hooks)


if __name__ == "__main__":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

# Command line params
RUNNER_CLASS = "test_harness_client.py"
RUNNER_CLASS_PATH = "/root/python_testing/rpc_client/"
RUNNER_CLASS_PATH = "/root/python_testing/"
EXECUTABLE = "python3"


Expand All @@ -59,6 +59,7 @@ class PythonTestCase(TestCase):
def __init__(self, test_case_execution: TestCaseExecution) -> None:
super().__init__(test_case_execution=test_case_execution)
self.chip_tool: ChipTool
self.__runned = 0

def start(self, count: int) -> None:
pass
Expand Down Expand Up @@ -177,7 +178,7 @@ def class_factory(cls, test: PythonTest, python_test_version: str) -> Type[T]:
@classmethod
def __class_factory(cls, test: PythonTest, python_test_version: str) -> Type[T]:
"""Common class factory method for all subclasses of PythonTestCase."""
identifier = cls.__test_identifier(test.name)
identifier = test.name
class_name = cls.__class_name(identifier)
title = identifier

Expand All @@ -189,10 +190,10 @@ def __class_factory(cls, test: PythonTest, python_test_version: str) -> Type[T]:
"python_test_version": python_test_version,
"chip_tool_test_identifier": class_name,
"metadata": {
"public_id": identifier,
"public_id": test.name,
"version": "0.0.1",
"title": title,
"description": test.name,
"description": test.description,
},
},
)
Expand Down Expand Up @@ -239,7 +240,7 @@ async def execute(self) -> None:
continue

self.__handle_update(update)
await sleep(0.1)
await sleep(0.001)
finally:
pass

Expand All @@ -257,7 +258,6 @@ def __call_function_from_name(self, obj, func_name, kwargs) -> None: # type: ig

async def cleanup(self) -> None:
logger.info("Test Cleanup")
self.chip_tool.destroy_device()


class PythonChipToolTestCase(PythonTestCase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,6 @@ def class_factory(
cls, suite_type: SuiteType, name: str, python_test_version: str
) -> Type[T]:
"""Dynamically declares a subclass based on the type of test suite."""
suite_class = ChipToolPythonTestSuite

return suite_class.__class_factory(
name=name, python_test_version=python_test_version
)

@classmethod
def __class_factory(cls, name: str, python_test_version: str) -> Type[T]:
"""Common class factory method for all subclasses of PythonTestSuite."""

return type(
name,
(cls,),
Expand All @@ -71,9 +61,3 @@ def __class_factory(cls, name: str, python_test_version: str) -> Type[T]:
},
},
)


class ChipToolPythonTestSuite(PythonTestSuite):
async def setup(self) -> None:
"""Due top multi inheritance, we need to call setup on both super classes."""
await PythonTestSuite.setup(self)
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@
class YamlTest(YamlModelMixin, MatterTest):
def __init__(self, **kwargs: Any) -> None:
super().__init__(steps=kwargs["tests"], **kwargs)
self.type: MatterTestType.MANUAL # type: ignore
self.type = MatterTestType.MANUAL

0 comments on commit cee194f

Please sign in to comment.