mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
better coverage for part/models
- Increase from 57% to 67%
This commit is contained in:
parent
f36f02b27f
commit
2ab8276672
@ -64,3 +64,13 @@ class CategoryTest(TestCase):
|
||||
self.assertEqual(self.p1.partcount, 3)
|
||||
self.assertEqual(self.p2.partcount, 3)
|
||||
self.assertEqual(self.p3.partcount, 1)
|
||||
|
||||
def test_delete(self):
|
||||
self.assertEqual(Part.objects.filter(category=self.p1).count(), 0)
|
||||
|
||||
# Delete p2 (it has 2 direct parts and one child category)
|
||||
self.p2.delete()
|
||||
|
||||
self.assertEqual(Part.objects.filter(category=self.p1).count(), 2)
|
||||
|
||||
self.assertEqual(PartCategory.objects.get(pk=self.p3.id).parent, self.p1)
|
||||
|
@ -1,6 +1,9 @@
|
||||
from django.test import TestCase
|
||||
|
||||
import os
|
||||
|
||||
from .models import Part, PartCategory
|
||||
from .models import rename_part_image
|
||||
|
||||
|
||||
class SimplePartTest(TestCase):
|
||||
@ -21,3 +24,15 @@ class SimplePartTest(TestCase):
|
||||
def test_category(self):
|
||||
self.assertEqual(self.px.category_path, '')
|
||||
self.assertEqual(self.pz.category_path, 'TLC')
|
||||
|
||||
def test_rename_img(self):
|
||||
img = rename_part_image(self.px, 'hello.png')
|
||||
self.assertEqual(img, os.path.join('part_images', 'part_1_img.png'))
|
||||
|
||||
img = rename_part_image(self.pz, 'test')
|
||||
self.assertEqual(img, os.path.join('part_images', 'part_3_img'))
|
||||
|
||||
def test_stock(self):
|
||||
# Stock should initially be zero
|
||||
self.assertEqual(self.px.total_stock, 0)
|
||||
self.assertEqual(self.py.available_stock, 0)
|
Loading…
Reference in New Issue
Block a user