2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-19 21:45:39 +00:00

Merge pull request #2630 from matmair/coverage-fixes

Coverage fixes
This commit is contained in:
Oliver
2022-02-16 07:55:12 +11:00
committed by GitHub
61 changed files with 299 additions and 223 deletions

View File

@ -40,6 +40,6 @@ class PartConfig(AppConfig):
item.part.trackable = True
item.part.clean()
item.part.save()
except (OperationalError, ProgrammingError):
except (OperationalError, ProgrammingError): # pragma: no cover
# Exception if the database has not been migrated yet
pass

View File

@ -11,7 +11,7 @@ import InvenTree.validators
import part.models
def attach_file(instance, filename):
def attach_file(instance, filename): # pragma: no cover
"""
Generate a filename for the uploaded attachment.

View File

@ -10,7 +10,7 @@ def update_tree(apps, schema_editor):
Part.objects.rebuild()
def nupdate_tree(apps, schema_editor):
def nupdate_tree(apps, schema_editor): # pragma: no cover
pass

View File

@ -33,7 +33,7 @@ def migrate_currencies(apps, schema_editor):
remap = {}
for index, row in enumerate(results):
for index, row in enumerate(results): # pragma: no cover
pk, suffix, description = row
suffix = suffix.strip().upper()
@ -57,7 +57,7 @@ def migrate_currencies(apps, schema_editor):
count = 0
for index, row in enumerate(results):
for index, row in enumerate(results): # pragma: no cover
pk, cost, currency_id, price, price_currency = row
# Copy the 'cost' field across to the 'price' field
@ -71,10 +71,10 @@ def migrate_currencies(apps, schema_editor):
count += 1
if count > 0:
if count > 0: # pragma: no cover
print(f"Updated {count} SupplierPriceBreak rows")
def reverse_currencies(apps, schema_editor):
def reverse_currencies(apps, schema_editor): # pragma: no cover
"""
Reverse the "update" process.

View File

@ -855,7 +855,7 @@ class PartAPIAggregationTest(InvenTreeAPITestCase):
return part
# We should never get here!
self.assertTrue(False)
self.assertTrue(False) # pragma: no cover
def test_stock_quantity(self):
"""

View File

@ -55,7 +55,7 @@ class BomItemTest(TestCase):
with self.assertRaises(django_exceptions.ValidationError):
# A validation error should be raised here
item = BomItem.objects.create(part=self.bob, sub_part=self.bob, quantity=7)
item.clean()
item.clean() # pragma: no cover
def test_integer_quantity(self):
"""

View File

@ -127,7 +127,7 @@ class CategoryTest(TestCase):
with self.assertRaises(ValidationError) as err:
cat.full_clean()
cat.save()
cat.save() # pragma: no cover
self.assertIn('Illegal character in name', str(err.exception.error_dict.get('name')))
@ -160,10 +160,6 @@ class CategoryTest(TestCase):
self.assertEqual(str(self.fasteners.default_location), 'Office/Drawer_1 - In my desk')
# Test that parts in this location return the same default location, too
for p in self.fasteners.children.all():
self.assert_equal(p.get_default_location().pathstring, 'Office/Drawer_1')
# Any part under electronics should default to 'Home'
r1 = Part.objects.get(name='R_2K2_0805')
self.assertIsNone(r1.default_location)

View File

@ -44,7 +44,7 @@ class TestParams(TestCase):
with self.assertRaises(django_exceptions.ValidationError):
t3 = PartParameterTemplate(name='aBcde', units='dd')
t3.full_clean()
t3.save()
t3.save() # pragma: no cover
class TestCategoryTemplates(TransactionTestCase):

View File

@ -110,7 +110,7 @@ class PartTest(TestCase):
try:
part.save()
self.assertTrue(False)
self.assertTrue(False) # pragma: no cover
except:
pass