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
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,10 @@ def __parse_python_tests(
and collection_type != CollectionType.MANDATORY
):
suites[SuiteType.NO_COMMISSIONING].add_test_case(test_case)
elif collection_type != CollectionType.MANDATORY:
elif (
python_test_type != PythonTestType.MANDATORY
and collection_type != CollectionType.MANDATORY
):
suites[SuiteType.LEGACY].add_test_case(test_case)

return [s for s in list(suites.values()) if len(s.test_cases) != 0]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"sdk_sha": "aabbccddeeff11223344556677889900",
"tests": [
{
"class_name": "TC_SameClass",
"desc": "TC TC_SameClass description 1",
"function": "test_TC_SC_1_1",
"path": "sdk/TC_SameClass",
"pics": [],
"steps": [
{
"description": "Step 1",
"expectation": "",
"is_commissioning": false,
"test_plan_number": 1
}
]
},
{
"class_name": "TC_DeviceConformance",
"desc": "TC_IDM_10_2 description",
"function": "test_TC_IDM_10_2",
"path": "sdk/TC_DeviceConformance",
"pics": [],
"steps": [
{
"description": "Run entire test",
"expectation": "",
"is_commissioning": false,
"test_plan_number": 1
}
]
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@
PythonCaseDeclaration,
PythonCollectionDeclaration,
)
from ...python_testing.sdk_python_tests import sdk_python_test_collection
from ...python_testing.sdk_python_tests import (
sdk_mandatory_python_test_collection,
sdk_python_test_collection,
)


@pytest.fixture
Expand All @@ -42,6 +45,23 @@ def python_test_collection() -> PythonCollectionDeclaration:
return sdk_python_test_collection(folder, tests_file_path=test_sdk_python_path)


def _load_collections_from(
tests_file_path: Path,
) -> tuple[PythonCollectionDeclaration, PythonCollectionDeclaration]:
with mock.patch.object(Path, "exists", return_value=True), mock.patch(
"test_collections.matter.sdk_tests.support.models.sdk_test_folder.open",
new=mock.mock_open(read_data="unit-test-python-version"),
):
folder = SDKTestFolder(path=tests_file_path, filename_pattern="TC_*")
non_mandatory = sdk_python_test_collection(
folder, tests_file_path=tests_file_path
)
mandatory = sdk_mandatory_python_test_collection(
folder, tests_file_path=tests_file_path
)
return non_mandatory, mandatory


def test_sdk_python_test_collection(
python_test_collection: PythonCollectionDeclaration,
) -> None:
Expand All @@ -64,3 +84,27 @@ def test_automated_suite(python_test_collection: PythonCollectionDeclaration) ->
type_count[test_case.test_type] += 1

assert type_count[MatterTestType.AUTOMATED] == expected_automated_test_cases


def test_mandatory_test_not_duplicated_across_collections() -> None:
"""Regression test for issue #1087.

A mandatory test case (e.g. TC_IDM_10_2) must be present in the
"Mandatory SDK Python Tests" collection only, and must not also be
duplicated into the "Old script format" (LEGACY) suite of the
non-mandatory "SDK Python Tests" collection.
"""
tests_file_path = (
Path(__file__).parent / "test_python_script/mandatory_tests_info.json"
)
non_mandatory_collection, mandatory_collection = _load_collections_from(
tests_file_path
)

for suite in non_mandatory_collection.test_suites.values():
assert "TC_IDM_10_2" not in suite.test_cases

mandatory_suite_name = "Python Testing Suite - Mandatories"
assert mandatory_suite_name in mandatory_collection.test_suites.keys()
mandatory_suite = mandatory_collection.test_suites[mandatory_suite_name]
assert "TC_IDM_10_2" in mandatory_suite.test_cases
Loading