mirror of
https://github.com/inventree/InvenTree.git
synced 2025-05-03 13:58:47 +00:00
More tests for Part
- barcode - category_path
This commit is contained in:
parent
3fda5a3925
commit
1f80e8c655
@ -36,4 +36,10 @@
|
|||||||
fields:
|
fields:
|
||||||
name: 'Widget'
|
name: 'Widget'
|
||||||
description: 'A watchamacallit'
|
description: 'A watchamacallit'
|
||||||
category: 7
|
category: 7
|
||||||
|
|
||||||
|
- model: part.part
|
||||||
|
fields:
|
||||||
|
name: 'Orphan'
|
||||||
|
description: 'A part without a category'
|
||||||
|
category: null
|
@ -217,6 +217,9 @@ class Part(models.Model):
|
|||||||
"Part",
|
"Part",
|
||||||
self.id,
|
self.id,
|
||||||
reverse('api-part-detail', kwargs={'pk': self.id}),
|
reverse('api-part-detail', kwargs={'pk': self.id}),
|
||||||
|
{
|
||||||
|
'name': self.name,
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
|
@ -28,6 +28,10 @@ class SimplePartTest(TestCase):
|
|||||||
def test_category(self):
|
def test_category(self):
|
||||||
self.assertEqual(str(self.C1.category), 'Electronics/Capacitors')
|
self.assertEqual(str(self.C1.category), 'Electronics/Capacitors')
|
||||||
|
|
||||||
|
orphan = Part.objects.get(name='Orphan')
|
||||||
|
self.assertIsNone(orphan.category)
|
||||||
|
self.assertEqual(orphan.category_path, '')
|
||||||
|
|
||||||
def test_rename_img(self):
|
def test_rename_img(self):
|
||||||
img = rename_part_image(self.R1, 'hello.png')
|
img = rename_part_image(self.R1, 'hello.png')
|
||||||
self.assertEqual(img, os.path.join('part_images', 'part_3_img.png'))
|
self.assertEqual(img, os.path.join('part_images', 'part_3_img.png'))
|
||||||
@ -41,3 +45,8 @@ class SimplePartTest(TestCase):
|
|||||||
for r in res:
|
for r in res:
|
||||||
self.assertEqual(r.total_stock, 0)
|
self.assertEqual(r.total_stock, 0)
|
||||||
self.assertEqual(r.available_stock, 0)
|
self.assertEqual(r.available_stock, 0)
|
||||||
|
|
||||||
|
def test_barcode(self):
|
||||||
|
barcode = self.R1.format_barcode()
|
||||||
|
self.assertIn('InvenTree', barcode)
|
||||||
|
self.assertIn(self.R1.name, barcode)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user