mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-18 21:15:41 +00:00
Simple and View test units
This commit is contained in:
@ -6,7 +6,7 @@ from django.core.exceptions import ValidationError
|
||||
|
||||
import os
|
||||
|
||||
from .models import Company, Contact, SupplierPart
|
||||
from .models import Company, Contact, ManufacturerPart, SupplierPart
|
||||
from .models import rename_company_image
|
||||
from part.models import Part
|
||||
|
||||
@ -22,6 +22,7 @@ class CompanySimpleTest(TestCase):
|
||||
'part',
|
||||
'location',
|
||||
'bom',
|
||||
'manufacturer_part',
|
||||
'supplier_part',
|
||||
'price_breaks',
|
||||
]
|
||||
@ -74,10 +75,10 @@ class CompanySimpleTest(TestCase):
|
||||
self.assertEqual(acme.supplied_part_count, 4)
|
||||
|
||||
self.assertTrue(appel.has_parts)
|
||||
self.assertEqual(appel.supplied_part_count, 2)
|
||||
self.assertEqual(appel.supplied_part_count, 3)
|
||||
|
||||
self.assertTrue(zerg.has_parts)
|
||||
self.assertEqual(zerg.supplied_part_count, 1)
|
||||
self.assertEqual(zerg.supplied_part_count, 2)
|
||||
|
||||
def test_price_breaks(self):
|
||||
|
||||
@ -166,3 +167,31 @@ class ContactSimpleTest(TestCase):
|
||||
# Remove the parent company
|
||||
Company.objects.get(pk=self.c.pk).delete()
|
||||
self.assertEqual(Contact.objects.count(), 0)
|
||||
|
||||
|
||||
class ManufacturerPartSimpleTest(TestCase):
|
||||
|
||||
fixtures = [
|
||||
'category',
|
||||
'company',
|
||||
'location',
|
||||
'part',
|
||||
'manufacturer_part',
|
||||
]
|
||||
|
||||
def setUp(self):
|
||||
# Create a manufacturer part
|
||||
self.part = Part.objects.get(pk=1)
|
||||
manufacturer = Company.objects.get(pk=1)
|
||||
MPN = 'MPN_TEST'
|
||||
|
||||
self.mp = ManufacturerPart.objects.create(part=self.part, manufacturer=manufacturer, MPN=MPN)
|
||||
|
||||
def test_exists(self):
|
||||
self.assertEqual(ManufacturerPart.objects.count(), 4)
|
||||
|
||||
def test_delete(self):
|
||||
# Remove a part
|
||||
Part.objects.get(pk=self.part.id).delete()
|
||||
# Check that ManufacturerPart was deleted
|
||||
self.assertEqual(ManufacturerPart.objects.count(), 3)
|
||||
|
Reference in New Issue
Block a user