From ce88deeb3bdd688b13003c7cef45d79641afe2b5 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sun, 13 Feb 2022 19:56:30 +0100 Subject: [PATCH] add test for system healt checks --- InvenTree/InvenTree/status.py | 6 +++--- InvenTree/InvenTree/tests.py | 10 ++++++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/InvenTree/InvenTree/status.py b/InvenTree/InvenTree/status.py index 1c2adb8821..cc9df701c6 100644 --- a/InvenTree/InvenTree/status.py +++ b/InvenTree/InvenTree/status.py @@ -89,15 +89,15 @@ def check_system_health(**kwargs): result = True - if not is_worker_running(**kwargs): + if not is_worker_running(**kwargs): # pragma: no cover result = False logger.warning(_("Background worker check failed")) - if not is_email_configured(): + if not is_email_configured(): # pragma: no cover result = False logger.warning(_("Email backend not configured")) - if not result: + if not result: # pragma: no cover logger.warning(_("InvenTree system health checks failed")) return result diff --git a/InvenTree/InvenTree/tests.py b/InvenTree/InvenTree/tests.py index 7fd62908a0..5caa59e158 100644 --- a/InvenTree/InvenTree/tests.py +++ b/InvenTree/InvenTree/tests.py @@ -12,6 +12,7 @@ from djmoney.contrib.exchange.exceptions import MissingRate from .validators import validate_overage, validate_part_name from . import helpers from . import version +from . import status from decimal import Decimal @@ -389,3 +390,12 @@ class CurrencyTests(TestCase): # Convert to a symbol which is not covered with self.assertRaises(MissingRate): convert_money(Money(100, 'GBP'), 'ZWL') + + +class TestStatus(TestCase): + """ + Unit tests for status functions + """ + + def test_check_system_healt(self): + self.assertTrue(status.check_system_health())