2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-07-01 03:00:54 +00:00

Add PEP8-naming extension for flake

- Enforcing python naming checks
This commit is contained in:
Oliver Walters
2020-11-12 21:53:04 +11:00
parent 47cbf3071d
commit ae7fbd6112
22 changed files with 84 additions and 78 deletions

View File

@ -617,10 +617,10 @@ class StockList(generics.ListCreateAPIView):
queryset = queryset.exclude(quantity__lte=0)
# Filter by internal part number
IPN = params.get('IPN', None)
ipn = params.get('IPN', None)
if IPN is not None:
queryset = queryset.filter(part__IPN=IPN)
if ipn is not None:
queryset = queryset.filter(part__IPN=ipn)
# Does the client wish to filter by the Part ID?
part_id = params.get('part', None)

View File

@ -621,12 +621,12 @@ class StockItem(MPTTModel):
return self.installedItemCount() > 0
@transaction.atomic
def installStockItem(self, otherItem, quantity, user, notes):
def installStockItem(self, other_item, quantity, user, notes):
"""
Install another stock item into this stock item.
Args
otherItem: The stock item to install into this stock item
other_item: The stock item to install into this stock item
quantity: The quantity of stock to install
user: The user performing the operation
notes: Any notes associated with the operation
@ -637,10 +637,10 @@ class StockItem(MPTTModel):
return False
# If the quantity is less than the stock item, split the stock!
stock_item = otherItem.splitStock(quantity, None, user)
stock_item = other_item.splitStock(quantity, None, user)
if stock_item is None:
stock_item = otherItem
stock_item = other_item
# Assign the other stock item into this one
stock_item.belongs_to = self

View File

@ -22,8 +22,9 @@ class StockAPITestCase(APITestCase):
def setUp(self):
# Create a user for auth
User = get_user_model()
self.user = User.objects.create_user('testuser', 'test@testing.com', 'password')
user = get_user_model()
self.user = user.objects.create_user('testuser', 'test@testing.com', 'password')
# Add the necessary permissions to the user
perms = [

View File

@ -23,8 +23,9 @@ class StockViewTestCase(TestCase):
super().setUp()
# Create a user
User = get_user_model()
self.user = User.objects.create_user(
user = get_user_model()
self.user = user.objects.create_user(
username='username',
email='user@email.com',
password='password'

View File

@ -38,12 +38,12 @@ class StockTest(TestCase):
self.drawer3 = StockLocation.objects.get(name='Drawer_3')
# Create a user
User = get_user_model()
User.objects.create_user('username', 'user@email.com', 'password')
user = get_user_model()
user.objects.create_user('username', 'user@email.com', 'password')
self.client.login(username='username', password='password')
self.user = User.objects.get(username='username')
self.user = user.objects.get(username='username')
# Ensure the MPTT objects are correctly rebuild
Part.objects.rebuild()
@ -221,21 +221,21 @@ class StockTest(TestCase):
def test_split_stock(self):
# Split the 1234 x 2K2 resistors in Drawer_1
N = StockItem.objects.filter(part=3).count()
n = StockItem.objects.filter(part=3).count()
stock = StockItem.objects.get(id=1234)
stock.splitStock(1000, None, self.user)
self.assertEqual(stock.quantity, 234)
# There should be a new stock item too!
self.assertEqual(StockItem.objects.filter(part=3).count(), N + 1)
self.assertEqual(StockItem.objects.filter(part=3).count(), n + 1)
# Try to split a negative quantity
stock.splitStock(-10, None, self.user)
self.assertEqual(StockItem.objects.filter(part=3).count(), N + 1)
self.assertEqual(StockItem.objects.filter(part=3).count(), n + 1)
stock.splitStock(stock.quantity, None, self.user)
self.assertEqual(StockItem.objects.filter(part=3).count(), N + 1)
self.assertEqual(StockItem.objects.filter(part=3).count(), n + 1)
def test_stocktake(self):
# Perform stocktake