Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix problem with sdk_tests collection using hardcoded paths #18

Merged
merged 1 commit into from
Nov 8, 2023
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
21 changes: 21 additions & 0 deletions test_collections/sdk_tests/support/paths.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#
# 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.
#

from pathlib import Path

SUPPORT_PATH = Path(__file__).parent
SDK_TESTS_ROOT = SUPPORT_PATH.parent
SDK_CHECKOUT_PATH = SDK_TESTS_ROOT / "sdk_checkout"
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@
#
from pathlib import Path

from test_collections.sdk_tests.support.paths import SDK_CHECKOUT_PATH

UNKNOWN_version = "Unknown"
VERSION_FILE_FILENAME = ".version"
VERSION_FILE_PATH = Path("/app/backend/test_collections/sdk_tests/sdk_checkout/")


class YamlTestFolder:
"""Representing a folder with Test YAML files.
Expand All @@ -31,9 +33,9 @@ def __init__(self, path: Path, filename_pattern: str = "*") -> None:
self.version = self.__version()

def __version(self) -> str:
"""Read version string from .version file in
"""Read version string from .version file in
/app/backend/test_collections/sdk_tests/sdk_checkout path."""
version_file_path = VERSION_FILE_PATH / VERSION_FILE_FILENAME
version_file_path = SDK_CHECKOUT_PATH / VERSION_FILE_FILENAME

if not version_file_path.exists():
return UNKNOWN_version
Expand Down
11 changes: 8 additions & 3 deletions test_collections/sdk_tests/support/yaml_tests/sdk_yaml_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

from loguru import logger

from test_collections.sdk_tests.support.paths import SDK_CHECKOUT_PATH

from .models.test_declarations import (
YamlCaseDeclaration,
YamlCollectionDeclaration,
Expand All @@ -38,11 +40,14 @@
# - Manual
###

SDK_YAML_PATH = Path("/app/backend/test_collections/sdk_tests/sdk_checkout/yaml_tests/yaml/sdk")
YAML_PATH = SDK_CHECKOUT_PATH / "yaml_tests/yaml"
SDK_YAML_PATH = YAML_PATH / "sdk"
SDK_YAML_TEST_FOLDER = YamlTestFolder(path=SDK_YAML_PATH, filename_pattern="Test_TC*")

CUSTOM_YAML_PATH = Path("/app/backend/test_collections/sdk_tests/sdk_checkout/yaml_tests/yaml/custom")
CUSTOM_YAML_TEST_FOLDER = YamlTestFolder(path=CUSTOM_YAML_PATH, filename_pattern="Test_TC*")
CUSTOM_YAML_PATH = YAML_PATH / "custom"
CUSTOM_YAML_TEST_FOLDER = YamlTestFolder(
path=CUSTOM_YAML_PATH, filename_pattern="Test_TC*"
)


def _init_test_suites(yaml_version: str) -> dict[SuiteType, YamlSuiteDeclaration]:
Expand Down