Skip to content

Commit

Permalink
Add get all methods for checker bundles and report modules (#28)
Browse files Browse the repository at this point in the history
Signed-off-by: patrickpa <patrick@ivex.ai>
  • Loading branch information
patrickpa authored Aug 21, 2024
1 parent 4eee5b2 commit 74f4d88
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
8 changes: 7 additions & 1 deletion qc_baselib/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions tests/test_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
)

0 comments on commit 74f4d88

Please sign in to comment.