diff --git a/script/todo/todo.py b/script/todo/todo.py index 5c3b3fb..15dfdad 100755 --- a/script/todo/todo.py +++ b/script/todo/todo.py @@ -998,6 +998,7 @@ class TODO: lst_choice = [ {"prompt_description": t("test_run_module")}, {"prompt_description": t("test_run_module_coverage")}, + {"prompt_description": t("test_run_unit_tests")}, ] help_info = self.fill_help_info(lst_choice) @@ -1010,6 +1011,8 @@ class TODO: self.execute_test_module(coverage=False) elif status == "2": self.execute_test_module(coverage=True) + elif status == "3": + self.execute_unit_tests() else: print(t("cmd_not_found")) @@ -1099,6 +1102,22 @@ class TODO: single_source_erplibre=True, ) + def execute_unit_tests(self): + print(f"\n--- {t('test_unit_running')} ---") + cmd = ( + ".venv.erplibre/bin/python -m unittest discover" + " -s test -p 'test_*.py' -v" + ) + status_code, output = self.execute.exec_command_live( + cmd, + source_erplibre=False, + return_status_and_output=True, + ) + if status_code == 0: + print(f"\n✅ {t('test_unit_success')}") + else: + print(f"\n❌ {t('test_unit_failed')}: {status_code}") + def execute_pip_audit(self): lst_version, lst_version_installed, odoo_installed_version = ( self.get_odoo_version() diff --git a/script/todo/todo_i18n.py b/script/todo/todo_i18n.py index 7fe1b46..81c1135 100644 --- a/script/todo/todo_i18n.py +++ b/script/todo/todo_i18n.py @@ -368,6 +368,22 @@ TRANSLATIONS = { "fr": "Tester un module avec couverture de code", "en": "Test a module with code coverage", }, + "test_run_unit_tests": { + "fr": "Tests unitaires ERPLibre", + "en": "ERPLibre unit tests", + }, + "test_unit_running": { + "fr": "Exécution des tests unitaires", + "en": "Running unit tests", + }, + "test_unit_success": { + "fr": "Tous les tests unitaires ont réussi", + "en": "All unit tests passed", + }, + "test_unit_failed": { + "fr": "Des tests unitaires ont échoué, code de sortie", + "en": "Some unit tests failed, exit code", + }, "test_enter_module_name": { "fr": "Nom du module à tester : ", "en": "Module name to test: ",