mirror of
https://github.com/inventree/InvenTree.git
synced 2025-07-10 23:14:13 +00:00
Docstring checks in QC checks (#3089)
* Add pre-commit to the stack * exclude static * Add locales to excludes * fix style errors * rename pipeline steps * also wait on precommit * make template matching simpler * Use the same code for python setup everywhere * use step and cache for python setup * move regular settings up into general envs * just use full update * Use invoke instead of static references * make setup actions more similar * use python3 * refactor names to be similar * fix runner version * fix references * remove incidential change * use matrix for os * Github can't do this right now * ignore docstyle errors * Add seperate docstring test * update flake call * do not fail on docstring * refactor setup into workflow * update reference * switch to action * resturcture * add bash statements * remove os from cache * update input checks * make code cleaner * fix boolean * no relative paths * install wheel by python * switch to install * revert back to simple wheel * refactor import export tests * move setup keys back to not disturbe tests * remove docstyle till that is fixed * update references * continue on error * add docstring test * use relativ action references * Change step / job docstrings * update to merge * reformat comments 1 * fix docstrings 2 * fix docstrings 3 * fix docstrings 4 * fix docstrings 5 * fix docstrings 6 * fix docstrings 7 * fix docstrings 8 * fix docstirns 9 * fix docstrings 10 * docstring adjustments * update the remaining docstrings * small docstring changes * fix function name * update support files for docstrings * Add missing args to docstrings * Remove outdated function * Add docstrings for the 'build' app * Make API code cleaner * add more docstrings for plugin app * Remove dead code for plugin settings No idea what that was even intended for * ignore __init__ files for docstrings * More docstrings * Update docstrings for the 'part' directory * Fixes for related_part functionality * Fix removed stuff from merge99676ee
* make more consistent * Show statistics for docstrings * add more docstrings * move specific register statements to make them clearer to understant * More docstrings for common * and more docstrings * and more * simpler call * docstrings for notifications * docstrings for common/tests * Add docs for common/models * Revert "move specific register statements to make them clearer to understant" This reverts commitca96654622
. * use typing here * Revert "Make API code cleaner" This reverts commit24fb68bd3e
. * docstring updates for the 'users' app * Add generic Meta info to simple Meta classes * remove unneeded unique_together statements * More simple metas * Remove unnecessary format specifier * Remove extra json format specifiers * Add docstrings for the 'plugin' app * Docstrings for the 'label' app * Add missing docstrings for the 'report' app * Fix build test regression * Fix top-level files * docstrings for InvenTree/InvenTree * reduce unneeded code * add docstrings * and more docstrings * more docstrings * more docstrings for stock * more docstrings * docstrings for order/views * Docstrings for various files in the 'order' app * Docstrings for order/test_api.py * Docstrings for order/serializers.py * Docstrings for order/admin.py * More docstrings for the order app * Add docstrings for the 'company' app * Add unit tests for rebuilding the reference fields * Prune out some more dead code * remove more dead code Co-authored-by: Oliver Walters <oliver.henry.walters@gmail.com>
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""Unit tests for the 'build' models"""
|
||||
|
||||
from django.test import TestCase
|
||||
|
||||
@ -12,13 +12,10 @@ from stock.models import StockItem
|
||||
|
||||
|
||||
class BuildTestBase(TestCase):
|
||||
"""
|
||||
Run some tests to ensure that the Build model is working properly.
|
||||
"""
|
||||
"""Run some tests to ensure that the Build model is working properly."""
|
||||
|
||||
def setUp(self):
|
||||
"""
|
||||
Initialize data to use for these tests.
|
||||
"""Initialize data to use for these tests.
|
||||
|
||||
The base Part 'assembly' has a BOM consisting of three parts:
|
||||
|
||||
@ -119,11 +116,10 @@ class BuildTestBase(TestCase):
|
||||
|
||||
|
||||
class BuildTest(BuildTestBase):
|
||||
"""Unit testing class for the Build model"""
|
||||
|
||||
def test_ref_int(self):
|
||||
"""
|
||||
Test the "integer reference" field used for natural sorting
|
||||
"""
|
||||
"""Test the "integer reference" field used for natural sorting"""
|
||||
|
||||
for ii in range(10):
|
||||
build = Build(
|
||||
@ -141,7 +137,7 @@ class BuildTest(BuildTestBase):
|
||||
self.assertEqual(build.reference_int, ii)
|
||||
|
||||
def test_init(self):
|
||||
# Perform some basic tests before we start the ball rolling
|
||||
"""Perform some basic tests before we start the ball rolling"""
|
||||
|
||||
self.assertEqual(StockItem.objects.count(), 10)
|
||||
|
||||
@ -166,7 +162,7 @@ class BuildTest(BuildTestBase):
|
||||
self.assertFalse(self.build.is_complete)
|
||||
|
||||
def test_build_item_clean(self):
|
||||
# Ensure that dodgy BuildItem objects cannot be created
|
||||
"""Ensure that dodgy BuildItem objects cannot be created"""
|
||||
|
||||
stock = StockItem.objects.create(part=self.assembly, quantity=99)
|
||||
|
||||
@ -193,7 +189,7 @@ class BuildTest(BuildTestBase):
|
||||
b.save()
|
||||
|
||||
def test_duplicate_bom_line(self):
|
||||
# Try to add a duplicate BOM item - it should be allowed
|
||||
"""Try to add a duplicate BOM item - it should be allowed"""
|
||||
|
||||
BomItem.objects.create(
|
||||
part=self.assembly,
|
||||
@ -202,12 +198,11 @@ class BuildTest(BuildTestBase):
|
||||
)
|
||||
|
||||
def allocate_stock(self, output, allocations):
|
||||
"""
|
||||
Allocate stock to this build, against a particular output
|
||||
"""Allocate stock to this build, against a particular output
|
||||
|
||||
Args:
|
||||
output - StockItem object (or None)
|
||||
allocations - Map of {StockItem: quantity}
|
||||
output: StockItem object (or None)
|
||||
allocations: Map of {StockItem: quantity}
|
||||
"""
|
||||
|
||||
for item, quantity in allocations.items():
|
||||
@ -219,9 +214,7 @@ class BuildTest(BuildTestBase):
|
||||
)
|
||||
|
||||
def test_partial_allocation(self):
|
||||
"""
|
||||
Test partial allocation of stock
|
||||
"""
|
||||
"""Test partial allocation of stock"""
|
||||
|
||||
# Fully allocate tracked stock against build output 1
|
||||
self.allocate_stock(
|
||||
@ -294,9 +287,7 @@ class BuildTest(BuildTestBase):
|
||||
self.assertTrue(self.build.are_untracked_parts_allocated())
|
||||
|
||||
def test_cancel(self):
|
||||
"""
|
||||
Test cancellation of the build
|
||||
"""
|
||||
"""Test cancellation of the build"""
|
||||
|
||||
# TODO
|
||||
|
||||
@ -309,9 +300,7 @@ class BuildTest(BuildTestBase):
|
||||
pass
|
||||
|
||||
def test_complete(self):
|
||||
"""
|
||||
Test completion of a build output
|
||||
"""
|
||||
"""Test completion of a build output"""
|
||||
|
||||
self.stock_1_1.quantity = 1000
|
||||
self.stock_1_1.save()
|
||||
@ -385,12 +374,10 @@ class BuildTest(BuildTestBase):
|
||||
|
||||
|
||||
class AutoAllocationTests(BuildTestBase):
|
||||
"""
|
||||
Tests for auto allocating stock against a build order
|
||||
"""
|
||||
"""Tests for auto allocating stock against a build order"""
|
||||
|
||||
def setUp(self):
|
||||
|
||||
"""Init routines for this unit test class"""
|
||||
super().setUp()
|
||||
|
||||
# Add a "substitute" part for bom_item_2
|
||||
@ -411,8 +398,7 @@ class AutoAllocationTests(BuildTestBase):
|
||||
)
|
||||
|
||||
def test_auto_allocate(self):
|
||||
"""
|
||||
Run the 'auto-allocate' function. What do we expect to happen?
|
||||
"""Run the 'auto-allocate' function. What do we expect to happen?
|
||||
|
||||
There are two "untracked" parts:
|
||||
- sub_part_1 (quantity 5 per BOM = 50 required total) / 103 in stock (2 items)
|
||||
@ -474,9 +460,7 @@ class AutoAllocationTests(BuildTestBase):
|
||||
self.assertTrue(self.build.is_bom_item_allocated(self.bom_item_2))
|
||||
|
||||
def test_fully_auto(self):
|
||||
"""
|
||||
We should be able to auto-allocate against a build in a single go
|
||||
"""
|
||||
"""We should be able to auto-allocate against a build in a single go"""
|
||||
|
||||
self.build.auto_allocate_stock(
|
||||
interchangeable=True,
|
||||
|
Reference in New Issue
Block a user