Add python tests model classes #19
15 errors
Black found 15 errors
Annotations
github-actions / Black
/home/runner/work/certification-tool-backend/certification-tool-backend/app/test_engine/models/manual_test_case.py#L154-L166
with file.file as f:
for line in f:
try:
logger.info(line.decode("utf-8").strip())
except UnicodeDecodeError:
- logger.warning("WARNING: The following line contained invalid UTF-8. Some content was replaced with: �")
- logger.info(line.decode("utf-8", errors='replace').strip())
+ logger.warning(
+ "WARNING: The following line contained invalid UTF-8. Some content was replaced with: �"
+ )
+ logger.info(line.decode("utf-8", errors="replace").strip())
logger.info("---- End of Manual Log ----")
class ManualTestCase(TestCase, UserPromptSupport):
"""Test case used to generate all manual test cases.
github-actions / Black
/home/runner/work/certification-tool-backend/certification-tool-backend/app/tests/python_tests/test_python_folder.py#L52-L60
_ = python_folder.python_file_paths()
path_glob.assert_called_once_with("*.py")
path_glob.reset_mock()
pattern = "TC_*"
- python_test_folder = PythonTestFolder(test_python_path, filename_pattern=pattern)
+ python_test_folder = PythonTestFolder(
+ test_python_path, filename_pattern=pattern
+ )
_ = python_test_folder.python_file_paths()
path_glob.assert_called_once_with(f"{pattern}.py")
github-actions / Black
/home/runner/work/certification-tool-backend/certification-tool-backend/app/tests/python_tests/test_python_parser.py#L67-L78
new=mock.mock_open(read_data=sample_invalid_python_file_content),
):
try:
parse_python_test(file_path)
except PythonParserException as e:
- assert "Test Case file does not have methods desc_file or steps_file" == str(e)
+ assert (
+ "Test Case file does not have methods desc_file or steps_file" == str(e)
+ )
def test_python_file_parser() -> None:
file_path = Path("/test/file.py")
github-actions / Black
/home/runner/work/certification-tool-backend/certification-tool-backend/app/tests/python_tests/test_python_script/UnitTest_TC_ACL_1_1_Automated.py#L1-L21
-
- #
- # Copyright (c) 2023 Project CHIP Authors
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
+#
+# Copyright (c) 2023 Project CHIP Authors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
# Copyright (c) 2021 Project CHIP Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
github-actions / Black
/home/runner/work/certification-tool-backend/certification-tool-backend/app/tests/python_tests/test_python_script/UnitTest_TC_ACL_1_1_Automated.py#L31-L43
"""
This is just a sample test case that should come from SDK.
It should not compile or run.
"""
+
+
class TC_Sample(MatterBaseTest):
-
def desc_TC_Sample(self) -> str:
return "Sample TC Description"
def steps_TC_Sample(self) -> list[TestStep]:
steps = [
github-actions / Black
/home/runner/work/certification-tool-backend/certification-tool-backend/app/tests/python_tests/test_python_script/UnitTest_TC_ACL_1_1_Automated.py#L46-L52
]
return steps
@async_test_body
async def test_steps_TC_Sample(self):
- print("Test execution")
+ print("Test execution")
github-actions / Black
/home/runner/work/certification-tool-backend/certification-tool-backend/app/tests/python_tests/test_python_test_declarations.py#L17-L28
from test_collections.sdk_tests.support.python_testing.models.test_declarations import (
PythonCaseDeclaration,
PythonSuiteDeclaration,
)
-from test_collections.sdk_tests.support.python_testing.models.test_suite import SuiteType
+from test_collections.sdk_tests.support.python_testing.models.test_suite import (
+ SuiteType,
+)
from test_collections.sdk_tests.support.python_testing.models.python_test_models import (
PythonTest,
)
github-actions / Black
/home/runner/work/certification-tool-backend/certification-tool-backend/app/tests/python_tests/test_python_test_suite.py#L46-L57
def test_python_test_suite_python_version() -> None:
"""Test that test suite python version is set correctly in class factory."""
python_test_version = "best_version"
# Create a subclass of PythonTestSuite
suite_class: Type[PythonTestSuite] = PythonTestSuite.class_factory(
- suite_type=SuiteType.AUTOMATED, name="SomeSuite", python_test_version=python_test_version
+ suite_type=SuiteType.AUTOMATED,
+ name="SomeSuite",
+ python_test_version=python_test_version,
)
assert suite_class.python_test_version == python_test_version
github-actions / Black
/home/runner/work/certification-tool-backend/certification-tool-backend/app/tests/python_tests/test_python_test_suite.py#L94-L105
"""Test that both PythonTestSuite.setup and ChipToolSuite.setup are called when
PythonChipToolsSuite.setup is called. We do this as PythonChipToolsSuite inherits from
both PythonTestSuite and ChipToolSuite."""
suite_class: Type[PythonTestSuite] = PythonTestSuite.class_factory(
- suite_type=SuiteType.AUTOMATED, name="SomeSuite", python_test_version="Some version"
+ suite_type=SuiteType.AUTOMATED,
+ name="SomeSuite",
+ python_test_version="Some version",
)
suite_instance = suite_class(TestSuiteExecution())
with mock.patch(
github-actions / Black
/home/runner/work/certification-tool-backend/certification-tool-backend/app/tests/python_tests/test_python_test_case.py#L46-L57
path: Optional[Path] = None,
) -> PythonTest:
return PythonTest(
name=name,
PICS=PICS,
- config=config,
+ config=config,
steps=steps,
type=type,
path=path,
)
github-actions / Black
/home/runner/work/certification-tool-backend/certification-tool-backend/app/tests/python_tests/test_python_test_case.py#L243-L254
)
instance = case_class(TestCaseExecution())
# Assert all steps from python test are added
assert len(instance.test_steps) >= no_steps
- steps_from_python = [s for s in instance.test_steps if s.name == test_step.label]
+ steps_from_python = [
+ s for s in instance.test_steps if s.name == test_step.label
+ ]
assert len(steps_from_python) == no_steps
@pytest.mark.asyncio
async def test_setup_super_error_handling() -> None:
github-actions / Black
/home/runner/work/certification-tool-backend/certification-tool-backend/app/tests/yaml_tests/test_yaml_folder.py#L29-L52
# We mock open to read version_file_content and Path exists to ignore that we're
# testing with a fake path
with mock.patch(
"test_collections.sdk_tests.support.yaml_tests.models.yaml_test_folder.open",
new=mock.mock_open(read_data=version_file_content),
- ), mock.patch.object(
- target=Path, attribute="exists", return_value=True
- ) as _:
+ ), mock.patch.object(target=Path, attribute="exists", return_value=True) as _:
yaml_folder = YamlTestFolder(test_yaml_path)
assert yaml_folder.version == version_file_content
def test_yaml_folder_version_missing() -> None:
expected_version = "Unknown"
- with mock.patch.object(
- target=Path, attribute="exists", return_value=False
- ) as _:
+ with mock.patch.object(target=Path, attribute="exists", return_value=False) as _:
yaml_folder = YamlTestFolder(test_yaml_path)
assert yaml_folder.version == expected_version
def test_yaml_folder_filename_pattern() -> None:
github-actions / Black
/home/runner/work/certification-tool-backend/certification-tool-backend/app/tests/yaml_tests/test_sdk_yaml_collection.py#L31-L41
sdk_yaml_test_collection,
)
VERSION_FILE_FILENAME = ".version"
VERSION_FILE_PATH = Path("/app/backend/test_collections/sdk_tests/sdk_checkout/")
+
@pytest.fixture
def yaml_collection() -> YamlCollectionDeclaration:
test_sdk_yaml_path = Path(__file__).parent / "test_yamls"
folder = YamlTestFolder(path=test_sdk_yaml_path, filename_pattern="UnitTest_TC_*")
github-actions / Black
/home/runner/work/certification-tool-backend/certification-tool-backend/test_collections/sdk_tests/__init__.py#L12-L20
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from .support.yaml_tests import sdk_collection, custom_collection
+
# TODO The Python test support implementation is ongoing.
-# Uncomment line below when the implementation is done.
-#from .support.python_testing import sdk_python_collection
+# Uncomment line below when the implementation is done.
+# from .support.python_testing import sdk_python_collection
github-actions / Black
/home/runner/work/certification-tool-backend/certification-tool-backend/test_collections/sdk_tests/support/yaml_tests/__init__.py#L19-L25
# Test engine will auto load TestCollectionDeclarations declared inside the package
# initializer
sdk_collection: TestCollectionDeclaration = sdk_yaml_test_collection()
-custom_collection: TestCollectionDeclaration = custom_yaml_test_collection()
+custom_collection: TestCollectionDeclaration = custom_yaml_test_collection()