From 07faf26201af7a19fde3d6ac85bd7b25ad0fedef Mon Sep 17 00:00:00 2001 From: MikaKerman Date: Mon, 9 Sep 2024 10:06:37 +0300 Subject: [PATCH] added is_singular field to the TestSchema --- elementary/monitor/api/tests/schema.py | 1 + elementary/monitor/api/tests/tests.py | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/elementary/monitor/api/tests/schema.py b/elementary/monitor/api/tests/schema.py index 83664cfcd..7c2410aca 100644 --- a/elementary/monitor/api/tests/schema.py +++ b/elementary/monitor/api/tests/schema.py @@ -79,6 +79,7 @@ class TestSchema(BaseModel): display_name: str original_path: Optional[str] = None type: str + is_singular: Optional[bool] = None test_type: Optional[str] = None test_sub_type: Optional[str] = None test_params: dict diff --git a/elementary/monitor/api/tests/tests.py b/elementary/monitor/api/tests/tests.py index fce744d6d..aedbe41a9 100644 --- a/elementary/monitor/api/tests/tests.py +++ b/elementary/monitor/api/tests/tests.py @@ -443,6 +443,14 @@ def _get_normalized_full_path( return f"{package_name}/{original_path}" return original_path + @staticmethod + def _get_is_singular(original_path: Optional[str]) -> Optional[bool]: + return ( + (original_path.startswith("tests/") and original_path.endswith(".sql")) + if original_path + else None + ) + @classmethod def _parse_test_db_row(cls, test_db_row: TestDBRowSchema) -> TestSchema: latest_run_datetime = ( @@ -467,6 +475,7 @@ def _parse_test_db_row(cls, test_db_row: TestDBRowSchema) -> TestSchema: display_name=cls._get_display_name(test_db_row.name), original_path=test_db_row.original_path, type=test_db_row.type, + is_singular=cls._get_is_singular(test_db_row.original_path), test_type=test_db_row.test_type, test_sub_type=test_db_row.test_sub_type, test_params=test_db_row.test_params,