mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Adds unit tests for version number comparison
This commit is contained in:
parent
6ea846ce45
commit
24823adc6d
@ -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,
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user