diff --git a/InvenTree/InvenTree/tasks.py b/InvenTree/InvenTree/tasks.py index ca84f93ee7..96f53e1e4c 100644 --- a/InvenTree/InvenTree/tasks.py +++ b/InvenTree/InvenTree/tasks.py @@ -8,7 +8,6 @@ import logging from datetime import datetime, timedelta -from django_q.models import Success from django.core.exceptions import AppRegistryNotReady from django.db.utils import OperationalError, ProgrammingError @@ -52,6 +51,12 @@ def heartbeat(): (There is probably a less "hacky" way of achieving this)? """ + try: + from django_q.models import Success + logger.warning("Could not perform heartbeat task - App registry not ready") + except AppRegistryNotReady: + return + threshold = datetime.now() - timedelta(minutes=30) # Delete heartbeat results more than half an hour old, diff --git a/InvenTree/InvenTree/tests.py b/InvenTree/InvenTree/tests.py index 5fadb7b68d..0da45e9373 100644 --- a/InvenTree/InvenTree/tests.py +++ b/InvenTree/InvenTree/tests.py @@ -273,6 +273,9 @@ class TestSerialNumberExtraction(TestCase): class TestVersionNumber(TestCase): + """ + Unit tests for version number functions + """ def test_tuple(self): @@ -282,3 +285,18 @@ class TestVersionNumber(TestCase): s = '.'.join([str(i) for i in v]) self.assertTrue(s in version.inventreeVersion()) + + def test_comparison(self): + """ + Test direct comparison of version numbers + """ + + v_a = version.inventreeVersionTuple('1.2.0') + v_b = version.inventreeVersionTuple('1.2.3') + v_c = version.inventreeVersionTuple('1.2.4') + v_d = version.inventreeVersionTuple('2.0.0') + + self.assertTrue(v_b > v_a) + self.assertTrue(v_c > v_b) + self.assertTrue(v_d > v_c) + self.assertTrue(v_d > v_a)