diff --git a/InvenTree/company/fixtures/company.yaml b/InvenTree/company/fixtures/company.yaml new file mode 100644 index 0000000000..7f95b6ec26 --- /dev/null +++ b/InvenTree/company/fixtures/company.yaml @@ -0,0 +1,14 @@ +# Sample company data + +- model: company.company + fields: + name: ACME + description: A Cool Military Enterprise +- model: company.company + fields: + name: Appel Computers + description: Think more differenter +- model: company.company + fields: + name: Zerg Corp + description: We eat the competition \ No newline at end of file diff --git a/InvenTree/company/fixtures/supplier_part.yaml b/InvenTree/company/fixtures/supplier_part.yaml new file mode 100644 index 0000000000..8066375bf8 --- /dev/null +++ b/InvenTree/company/fixtures/supplier_part.yaml @@ -0,0 +1,24 @@ +# Supplier Parts + +# M2x4 LPHS from ACME +- model: company.supplierpart + pk: 1 + fields: + part: 1 + supplier: 1 + SKU: 'ACME0001' + +- model: company.supplierpart + pk: 2 + fields: + part: 1 + supplier: 1 + SKU: 'ACME0002' + +# M2x4 LPHS from Zerg Corp +- model: company.supplierpart + pk: 3 + fields: + part: 1 + supplier: 3 + SKU: 'ZERGLPHS' \ No newline at end of file diff --git a/InvenTree/company/tests.py b/InvenTree/company/tests.py index e5f5d99869..7b6661688d 100644 --- a/InvenTree/company/tests.py +++ b/InvenTree/company/tests.py @@ -8,6 +8,15 @@ from .models import rename_company_image class CompanySimpleTest(TestCase): + fixtures = [ + 'company', + 'category', + 'part', + 'location', + 'bom', + 'supplier_part', + ] + def setUp(self): Company.objects.create(name='ABC Co.', description='Seller of ABC products', @@ -17,7 +26,7 @@ class CompanySimpleTest(TestCase): is_supplier=True) def test_company_model(self): - c = Company.objects.get(pk=1) + c = Company.objects.get(name='ABC Co.') self.assertEqual(c.name, 'ABC Co.') self.assertEqual(str(c), 'ABC Co. - Seller of ABC products') @@ -34,9 +43,21 @@ class CompanySimpleTest(TestCase): self.assertEqual(rn, 'company_images' + os.path.sep + 'company_1_img') def test_part_count(self): - # Initially the company should have no associated parts - c = Company.objects.get(pk=1) - self.assertEqual(c.has_parts, False) + + acme = Company.objects.get(pk=1) + appel = Company.objects.get(pk=2) + zerg = Company.objects.get(pk=3) + + self.assertTrue(acme.has_parts) + self.assertEqual(acme.part_count, 2) + + self.assertFalse(appel.has_parts) + self.assertEqual(appel.part_count, 0) + + self.assertTrue(zerg.has_parts) + self.assertEqual(zerg.part_count, 1) + + # TODO - Add some supplier parts here