2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-12-14 08:19:54 +00:00

better coverage for part/models

- Increase from 57% to 67%
This commit is contained in:
Oliver Walters
2019-04-25 17:51:02 +10:00
parent f36f02b27f
commit 2ab8276672
2 changed files with 25 additions and 0 deletions

View File

@@ -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)