From 042956ad48be8cb10b082bf82950d3ddfdd3dc7e Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Mon, 28 Sep 2020 19:27:18 +1000 Subject: [PATCH 1/3] Fix unit test --- InvenTree/stock/tests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/InvenTree/stock/tests.py b/InvenTree/stock/tests.py index 1001ed12ea..18301cf49e 100644 --- a/InvenTree/stock/tests.py +++ b/InvenTree/stock/tests.py @@ -444,7 +444,7 @@ class TestResultTest(StockTest): status = item.requiredTestStatus() self.assertEqual(status['total'], 5) - self.assertEqual(status['passed'], 3) + self.assertEqual(status['passed'], 2) self.assertEqual(status['failed'], 1) self.assertFalse(item.passedAllRequiredTests()) From f409bfd72b7c22bc134055013d52abe913252279 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Mon, 28 Sep 2020 19:41:41 +1000 Subject: [PATCH 2/3] More fixes --- InvenTree/stock/fixtures/stock_tests.yaml | 2 +- InvenTree/stock/tests.py | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/InvenTree/stock/fixtures/stock_tests.yaml b/InvenTree/stock/fixtures/stock_tests.yaml index 7ee6f3b387..8a99e8b56b 100644 --- a/InvenTree/stock/fixtures/stock_tests.yaml +++ b/InvenTree/stock/fixtures/stock_tests.yaml @@ -62,7 +62,7 @@ pk: 8 fields: stock_item: 522 - test: 'Check that chair is GreEn ' + test: 'Check that chair is GreEn' result: True date: 2020-05-17 diff --git a/InvenTree/stock/tests.py b/InvenTree/stock/tests.py index 18301cf49e..fddd2c176b 100644 --- a/InvenTree/stock/tests.py +++ b/InvenTree/stock/tests.py @@ -3,6 +3,8 @@ from django.db.models import Sum from django.contrib.auth import get_user_model from django.core.exceptions import ValidationError +import datetime + from .models import StockLocation, StockItem, StockItemTracking from .models import StockItemTestResult from part.models import Part @@ -439,13 +441,14 @@ class TestResultTest(StockTest): self.assertIn(test, result_map.keys()) def test_test_results(self): + item = StockItem.objects.get(pk=522) status = item.requiredTestStatus() self.assertEqual(status['total'], 5) self.assertEqual(status['passed'], 2) - self.assertEqual(status['failed'], 1) + self.assertEqual(status['failed'], 2) self.assertFalse(item.passedAllRequiredTests()) @@ -460,6 +463,18 @@ class TestResultTest(StockTest): result=True ) + # Still should be failing at this point, + # as the most recent "apply paint" test was False + self.assertFalse(item.passedAllRequiredTests()) + + # Add a new test result against this required test + StockItemTestResult.objects.create( + stock_item=item, + test='apply paint', + date=datetime.datetime(2022, 12, 12), + result=True + ) + self.assertTrue(item.passedAllRequiredTests()) def test_duplicate_item_tests(self): From d8a74ad8b709904dfc656db1d615f2fc2f16e215 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Mon, 28 Sep 2020 20:08:08 +1000 Subject: [PATCH 3/3] Style fixes --- InvenTree/stock/tests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/InvenTree/stock/tests.py b/InvenTree/stock/tests.py index fddd2c176b..23cf6b3d02 100644 --- a/InvenTree/stock/tests.py +++ b/InvenTree/stock/tests.py @@ -464,7 +464,7 @@ class TestResultTest(StockTest): ) # Still should be failing at this point, - # as the most recent "apply paint" test was False + # as the most recent "apply paint" test was False self.assertFalse(item.passedAllRequiredTests()) # Add a new test result against this required test