From 74f4d88c6ef07233dec5a381cbc5451aa841bbd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20Abrah=C3=A3o?= Date: Wed, 21 Aug 2024 18:46:41 +0200 Subject: [PATCH] Add get all methods for checker bundles and report modules (#28) Signed-off-by: patrickpa --- qc_baselib/configuration.py | 8 +++++++- tests/test_configuration.py | 10 ++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/qc_baselib/configuration.py b/qc_baselib/configuration.py index 71e8b3a..cb6c8fb 100644 --- a/qc_baselib/configuration.py +++ b/qc_baselib/configuration.py @@ -3,7 +3,7 @@ # Public License, v. 2.0. If a copy of the MPL was not distributed # with this file, You can obtain one at https://mozilla.org/MPL/2.0/. -from typing import Union +from typing import Union, List from .models import config, common, IssueSeverity @@ -89,6 +89,12 @@ def _get_checker_bundle( return bundle + def get_all_checker_bundles(self) -> List[config.CheckerBundleType]: + return self._configuration.checker_bundles + + def get_all_report_modules(self) -> List[config.ReportModuleType]: + return self._configuration.reports + def get_config_param(self, param_name: str) -> Union[str, int, float, None]: if len(self._configuration.params) == 0: return None diff --git a/tests/test_configuration.py b/tests/test_configuration.py index 33fa3a8..338519c 100644 --- a/tests/test_configuration.py +++ b/tests/test_configuration.py @@ -196,3 +196,13 @@ def test_config_file_parse_order_independence() -> None: assert len(config_ordered._configuration.params) == len( config_unordered._configuration.params ) + + +def test_get_all_methods() -> None: + config = Configuration() + config.load_from_file(os.path.join(TEST_DATA_BASE_PATH, "unordered_config.xml")) + + assert len(config._configuration.reports) == len(config.get_all_report_modules()) + assert len(config._configuration.checker_bundles) == len( + config.get_all_checker_bundles() + )