From 1eb9b395bc976f1e3d7fabf1e7dadd6f9096fc96 Mon Sep 17 00:00:00 2001 From: Matthias Date: Wed, 29 Dec 2021 15:43:34 +0100 Subject: [PATCH] more complicated tests --- InvenTree/InvenTree/tests.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/InvenTree/InvenTree/tests.py b/InvenTree/InvenTree/tests.py index 843cf0db3c..e4ab3c7a0c 100644 --- a/InvenTree/InvenTree/tests.py +++ b/InvenTree/InvenTree/tests.py @@ -301,6 +301,26 @@ class TestSerialNumberExtraction(TestCase): e("10, a, 7-70j", 4, 1) + def test_combinations(self): + e = helpers.extract_serial_numbers + + sn = e("1 3-5 9+2", 7, 1) + self.assertEqual(len(sn), 7) + self.assertEqual(sn, ['1', 3, 4, 5, 9, 10, 11]) + + sn = e("1,3-5,9+2", 7, 1) + self.assertEqual(len(sn), 7) + self.assertEqual(sn, ['1', 3, 4, 5, 9, 10, 11]) + + sn = e("~+2", 3, 14) + self.assertEqual(len(sn), 3) + self.assertEqual(sn, [14, 15, 16]) + + sn = e("~+", 2, 14) + self.assertEqual(len(sn), 2) + self.assertEqual(sn, [14, 15]) + + class TestVersionNumber(TestCase): """ Unit tests for version number functions