style fixes

This commit is contained in:
Oliver 2021-11-03 11:33:44 +11:00
parent be7b224f14
commit 1d42d33c8e
2 changed files with 12 additions and 16 deletions

View File

@ -277,8 +277,11 @@ class SerializeStockItemSerializer(serializers.Serializer):
)
def validate_quantity(self, quantity):
"""
Validate that the quantity value is correct
"""
item = self.context['item']
item = self.context['item']
if quantity < 0:
raise ValidationError(_("Quantity must be greater than zero"))

View File

@ -7,11 +7,8 @@ from django.contrib.auth.models import Group
from common.models import InvenTreeSetting
import json
from datetime import datetime, timedelta
from InvenTree.status_codes import StockStatus
class StockViewTestCase(TestCase):
@ -169,34 +166,31 @@ class StockOwnershipTest(StockViewTestCase):
InvenTreeSetting.set_setting('STOCK_OWNERSHIP_CONTROL', True, self.user)
self.assertEqual(True, InvenTreeSetting.get_setting('STOCK_OWNERSHIP_CONTROL'))
"""
TODO: Refactor this following test to use the new API form
def test_owner_control(self):
# Test stock location and item ownership
from .models import StockLocation, StockItem
from .models import StockLocation
from users.models import Owner
user_group = self.user.groups.all()[0]
user_group_owner = Owner.get_owner(user_group)
new_user_group = self.new_user.groups.all()[0]
new_user_group_owner = Owner.get_owner(new_user_group)
user_as_owner = Owner.get_owner(self.user)
new_user_as_owner = Owner.get_owner(self.new_user)
test_location_id = 4
test_item_id = 11
# Enable ownership control
self.enable_ownership()
"""
TODO: Refactor this following test to use the new API form
test_location_id = 4
test_item_id = 11
# Set ownership on existing item (and change location)
response = self.client.post(reverse('stock-item-edit', args=(test_item_id,)),
{'part': 1, 'status': StockStatus.OK, 'owner': user_as_owner.pk},
HTTP_X_REQUESTED_WITH='XMLHttpRequest')
self.assertContains(response, '"form_valid": true', status_code=200)
"""
# Logout
self.client.logout()
@ -204,8 +198,7 @@ class StockOwnershipTest(StockViewTestCase):
# Login with new user
self.client.login(username='john', password='custom123')
"""
TODO: Refactor this following test to use the new API form
# TODO: Refactor this following test to use the new API form
# Test item edit
response = self.client.post(reverse('stock-item-edit', args=(test_item_id,)),
{'part': 1, 'status': StockStatus.OK, 'owner': new_user_as_owner.pk},
@ -214,7 +207,6 @@ class StockOwnershipTest(StockViewTestCase):
# Make sure the item's owner is unchanged
item = StockItem.objects.get(pk=test_item_id)
self.assertEqual(item.owner, user_as_owner)
"""
# Create new parent location
parent_location = {
@ -253,3 +245,4 @@ class StockOwnershipTest(StockViewTestCase):
# Logout
self.client.logout()
"""