Skip to content

Commit

Permalink
Fix prblem with sdk_tests collection using hardcoded paths
Browse files Browse the repository at this point in the history
  • Loading branch information
mikaelhm committed Nov 8, 2023
1 parent d2360b5 commit 7d2ac9e
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 6 deletions.
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

0 comments on commit 7d2ac9e

Please sign in to comment.