From 7ac7e8f9690971f5a8cf9c4404ad4fb25ff770ce Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Wed, 6 Jan 2021 23:38:01 +1100 Subject: [PATCH] Fixed unit test --- InvenTree/stock/test_api.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/InvenTree/stock/test_api.py b/InvenTree/stock/test_api.py index 520110469c..9b3e926456 100644 --- a/InvenTree/stock/test_api.py +++ b/InvenTree/stock/test_api.py @@ -15,6 +15,8 @@ from django.contrib.auth import get_user_model from InvenTree.helpers import addUserPermissions from InvenTree.status_codes import StockStatus +from common.models import InvenTreeSetting + from .models import StockItem, StockLocation @@ -36,6 +38,9 @@ class StockAPITestCase(APITestCase): self.user = user.objects.create_user('testuser', 'test@testing.com', 'password') + self.user.is_staff = True + self.user.save() + # Add the necessary permissions to the user perms = [ 'view_stockitemtestresult', @@ -223,6 +228,13 @@ class StockItemListTest(StockAPITestCase): Filter StockItem by expiry status """ + # First, we can assume that the 'stock expiry' feature is disabled + response = self.get_stock(expired=1) + self.assertEqual(len(response), 19) + + # Now, ensure that the expiry date feature is enabled! + InvenTreeSetting.set_setting('STOCK_ENABLE_EXPIRY', True, self.user) + response = self.get_stock(expired=1) self.assertEqual(len(response), 1)