diff --git a/modules/ErrorHistory/ErrorDatabaseSqlite.hpp b/modules/ErrorHistory/ErrorDatabaseSqlite.hpp index 28411b4cc3..4f7f71a51f 100644 --- a/modules/ErrorHistory/ErrorDatabaseSqlite.hpp +++ b/modules/ErrorHistory/ErrorDatabaseSqlite.hpp @@ -14,7 +14,7 @@ namespace module { class ErrorDatabaseSqlite : public Everest::error::ErrorDatabase { public: - ErrorDatabaseSqlite(const fs::path& db_path_, const bool reset_ = false); + explicit ErrorDatabaseSqlite(const fs::path& db_path_, const bool reset_ = false); void add_error(Everest::error::ErrorPtr error) override; std::list diff --git a/modules/ErrorHistory/tests/helpers.hpp b/modules/ErrorHistory/tests/helpers.hpp index d13b3c37db..490a71e24c 100644 --- a/modules/ErrorHistory/tests/helpers.hpp +++ b/modules/ErrorHistory/tests/helpers.hpp @@ -44,7 +44,7 @@ void check_expected_errors_in_list(const std::vector& /// class TestDatabase { public: - TestDatabase(const fs::path& db_path_, const bool reset_ = false); + explicit TestDatabase(const fs::path& db_path_, const bool reset_ = false); ~TestDatabase(); void add_error(Everest::error::ErrorPtr error); std::list get_errors(const std::list& filters) const; diff --git a/tests/core_tests/error_history_tests.py b/tests/core_tests/error_history_tests.py index 23c64c20fe..b4a28f15bb 100644 --- a/tests/core_tests/error_history_tests.py +++ b/tests/core_tests/error_history_tests.py @@ -2,7 +2,6 @@ # Copyright Pionix GmbH and Contributors to EVerest from copy import deepcopy -import logging from typing import Dict import uuid import pytest @@ -24,20 +23,22 @@ def assert_error(expected_error, error): def assert_errors(expected_errors, errors): assert len(expected_errors) == len(errors) - for index_exp in range(len(expected_errors)): + for exp_err in expected_errors: index = None - for i in range(len(errors)): - if expected_errors[index_exp]['uuid'] == errors[i]['uuid']: + for (i, err) in zip(range(len(errors)), errors): + if exp_err['uuid'] == err['uuid']: + if index is not None: + assert False, f'Found multiple errors with uuid {exp_err["uuid"]}' index = i - break + assert index is not None - assert_error(expected_errors[index_exp], errors[index]) + assert_error(exp_err, err) class ErrorHistoryModuleConfigurationStrategy(EverestConfigAdjustmentStrategy): def __init__(self, db_name): self.db_name = db_name def adjust_everest_configuration(self, everest_config: Dict) -> Dict: - db_path = f'/tmp/{self.db_name}.db' + db_path = f'{self.db_name}.db' adjusted_config = deepcopy(everest_config) module_config = adjusted_config['active_modules']['error_history'] module_config['config_implementation'] = { @@ -53,7 +54,6 @@ def __init__(self): super().__init__(db_name=db_name) def adjust_everest_configuration(self, everest_config: Dict) -> Dict: return super().adjust_everest_configuration(everest_config) - class TestErrorHistory: """