mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Update test fixtures
- Can't assume that pk values will be assigned sensibly! - Need to hard-code them in
This commit is contained in:
parent
bc2f131144
commit
911727f7b7
@ -31,7 +31,8 @@ script:
|
|||||||
- cd InvenTree && python3 manage.py makemigrations && cd ..
|
- cd InvenTree && python3 manage.py makemigrations && cd ..
|
||||||
- python3 ci/check_migration_files.py
|
- python3 ci/check_migration_files.py
|
||||||
- invoke coverage
|
- invoke coverage
|
||||||
- invoke test --database=mysql
|
- cd InvenTree && python3 manage.py test --settings=InvenTree.ci_mysql && cd ..
|
||||||
|
- cd InvenTree && python3 manage.py test --settings=InvenTree.ci_postgresql && cd ..
|
||||||
- invoke translate
|
- invoke translate
|
||||||
- invoke style
|
- invoke style
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
# Construct build objects
|
# Construct build objects
|
||||||
|
|
||||||
- model: build.build
|
- model: build.build
|
||||||
|
pk: 1
|
||||||
fields:
|
fields:
|
||||||
part: 25
|
part: 25
|
||||||
batch: 'B1'
|
batch: 'B1'
|
||||||
@ -16,6 +17,7 @@
|
|||||||
tree_id: 0
|
tree_id: 0
|
||||||
|
|
||||||
- model: build.build
|
- model: build.build
|
||||||
|
pk: 2
|
||||||
fields:
|
fields:
|
||||||
part: 50
|
part: 50
|
||||||
title: 'Making things'
|
title: 'Making things'
|
||||||
|
@ -203,22 +203,25 @@ class BuildTest(TestCase):
|
|||||||
# - Three for the split items assigned to the build
|
# - Three for the split items assigned to the build
|
||||||
self.assertEqual(StockItem.objects.count(), 16)
|
self.assertEqual(StockItem.objects.count(), 16)
|
||||||
|
|
||||||
|
A = StockItem.objects.get(pk=self.stock_1_1.pk)
|
||||||
|
B = StockItem.objects.get(pk=self.stock_1_2.pk)
|
||||||
|
C = StockItem.objects.get(pk=self.stock_2_1.pk)
|
||||||
|
|
||||||
# Stock should have been subtracted from the original items
|
# Stock should have been subtracted from the original items
|
||||||
self.assertEqual(StockItem.objects.get(pk=1).quantity, 950)
|
self.assertEqual(A.quantity, 950)
|
||||||
self.assertEqual(StockItem.objects.get(pk=2).quantity, 50)
|
self.assertEqual(B.quantity, 50)
|
||||||
self.assertEqual(StockItem.objects.get(pk=3).quantity, 4750)
|
self.assertEqual(C.quantity, 4750)
|
||||||
|
|
||||||
# New stock items created and assigned to the build
|
# New stock items should have also been allocated to the build
|
||||||
self.assertEqual(StockItem.objects.get(pk=4).quantity, 50)
|
allocated = StockItem.objects.filter(build_order=self.build)
|
||||||
self.assertEqual(StockItem.objects.get(pk=4).build_order, self.build)
|
|
||||||
|
|
||||||
self.assertEqual(StockItem.objects.get(pk=5).quantity, 50)
|
self.assertEqual(allocated.count(), 3)
|
||||||
self.assertEqual(StockItem.objects.get(pk=5).build_order, self.build)
|
|
||||||
|
|
||||||
self.assertEqual(StockItem.objects.get(pk=6).quantity, 250)
|
q = sum([item.quantity for item in allocated.all()])
|
||||||
self.assertEqual(StockItem.objects.get(pk=6).build_order, self.build)
|
|
||||||
|
self.assertEqual(q, 350)
|
||||||
|
|
||||||
# And a new stock item created for the build output
|
# And 10 new stock items created for the build output
|
||||||
self.assertEqual(StockItem.objects.get(pk=7).quantity, 1)
|
outputs = StockItem.objects.filter(build=self.build)
|
||||||
self.assertEqual(StockItem.objects.get(pk=7).serial, 1)
|
|
||||||
self.assertEqual(StockItem.objects.get(pk=7).build, self.build)
|
self.assertEqual(outputs.count(), 10)
|
||||||
|
@ -3,18 +3,21 @@
|
|||||||
# Price breaks for ACME0001
|
# Price breaks for ACME0001
|
||||||
|
|
||||||
- model: company.supplierpricebreak
|
- model: company.supplierpricebreak
|
||||||
|
pk: 1
|
||||||
fields:
|
fields:
|
||||||
part: 1
|
part: 1
|
||||||
quantity: 1
|
quantity: 1
|
||||||
cost: 10
|
cost: 10
|
||||||
|
|
||||||
- model: company.supplierpricebreak
|
- model: company.supplierpricebreak
|
||||||
|
pk: 2
|
||||||
fields:
|
fields:
|
||||||
part: 1
|
part: 1
|
||||||
quantity: 5
|
quantity: 5
|
||||||
cost: 7.50
|
cost: 7.50
|
||||||
|
|
||||||
- model: company.supplierpricebreak
|
- model: company.supplierpricebreak
|
||||||
|
pk: 3
|
||||||
fields:
|
fields:
|
||||||
part: 1
|
part: 1
|
||||||
quantity: 25
|
quantity: 25
|
||||||
@ -22,12 +25,14 @@
|
|||||||
|
|
||||||
# Price breaks for ACME0002
|
# Price breaks for ACME0002
|
||||||
- model: company.supplierpricebreak
|
- model: company.supplierpricebreak
|
||||||
|
pk: 4
|
||||||
fields:
|
fields:
|
||||||
part: 2
|
part: 2
|
||||||
quantity: 5
|
quantity: 5
|
||||||
cost: 7.00
|
cost: 7.00
|
||||||
|
|
||||||
- model: company.supplierpricebreak
|
- model: company.supplierpricebreak
|
||||||
|
pk: 5
|
||||||
fields:
|
fields:
|
||||||
part: 2
|
part: 2
|
||||||
quantity: 50
|
quantity: 50
|
||||||
@ -35,12 +40,14 @@
|
|||||||
|
|
||||||
# Price breaks for ZERGLPHS
|
# Price breaks for ZERGLPHS
|
||||||
- model: company.supplierpricebreak
|
- model: company.supplierpricebreak
|
||||||
|
pk: 6
|
||||||
fields:
|
fields:
|
||||||
part: 4
|
part: 4
|
||||||
quantity: 25
|
quantity: 25
|
||||||
cost: 8
|
cost: 8
|
||||||
|
|
||||||
- model: company.supplierpricebreak
|
- model: company.supplierpricebreak
|
||||||
|
pk: 7
|
||||||
fields:
|
fields:
|
||||||
part: 4
|
part: 4
|
||||||
quantity: 100
|
quantity: 100
|
||||||
|
@ -113,17 +113,17 @@ class ContactSimpleTest(TestCase):
|
|||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
# Create a simple company
|
# Create a simple company
|
||||||
c = Company.objects.create(name='Test Corp.', description='We make stuff good')
|
self.c = Company.objects.create(name='Test Corp.', description='We make stuff good')
|
||||||
|
|
||||||
# Add some contacts
|
# Add some contacts
|
||||||
Contact.objects.create(name='Joe Smith', company=c)
|
Contact.objects.create(name='Joe Smith', company=self.c)
|
||||||
Contact.objects.create(name='Fred Smith', company=c)
|
Contact.objects.create(name='Fred Smith', company=self.c)
|
||||||
Contact.objects.create(name='Sally Smith', company=c)
|
Contact.objects.create(name='Sally Smith', company=self.c)
|
||||||
|
|
||||||
def test_exists(self):
|
def test_exists(self):
|
||||||
self.assertEqual(Contact.objects.count(), 3)
|
self.assertEqual(Contact.objects.count(), 3)
|
||||||
|
|
||||||
def test_delete(self):
|
def test_delete(self):
|
||||||
# Remove the parent company
|
# Remove the parent company
|
||||||
Company.objects.get(pk=1).delete()
|
Company.objects.get(pk=self.c.pk).delete()
|
||||||
self.assertEqual(Contact.objects.count(), 0)
|
self.assertEqual(Contact.objects.count(), 0)
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
# 250 x ACME0002 (M2x4 LPHS)
|
# 250 x ACME0002 (M2x4 LPHS)
|
||||||
# Partially received (50)
|
# Partially received (50)
|
||||||
- model: order.purchaseorderlineitem
|
- model: order.purchaseorderlineitem
|
||||||
|
pk: 2
|
||||||
fields:
|
fields:
|
||||||
order: 1
|
order: 1
|
||||||
part: 2
|
part: 2
|
||||||
@ -37,6 +38,7 @@
|
|||||||
|
|
||||||
# 1000 x ACME0003
|
# 1000 x ACME0003
|
||||||
- model: order.purchaseorderlineitem
|
- model: order.purchaseorderlineitem
|
||||||
|
pk: 3
|
||||||
fields:
|
fields:
|
||||||
order: 1
|
order: 1
|
||||||
part: 3
|
part: 3
|
||||||
|
@ -27,8 +27,8 @@ class SalesOrderTest(TestCase):
|
|||||||
self.part = Part.objects.create(name='Spanner', salable=True, description='A spanner that I sell')
|
self.part = Part.objects.create(name='Spanner', salable=True, description='A spanner that I sell')
|
||||||
|
|
||||||
# Create some stock!
|
# Create some stock!
|
||||||
StockItem.objects.create(part=self.part, quantity=100)
|
self.Sa = StockItem.objects.create(part=self.part, quantity=100)
|
||||||
StockItem.objects.create(part=self.part, quantity=200)
|
self.Sb = StockItem.objects.create(part=self.part, quantity=200)
|
||||||
|
|
||||||
# Create a SalesOrder to ship against
|
# Create a SalesOrder to ship against
|
||||||
self.order = SalesOrder.objects.create(
|
self.order = SalesOrder.objects.create(
|
||||||
@ -57,15 +57,16 @@ class SalesOrderTest(TestCase):
|
|||||||
SalesOrderLineItem.objects.create(order=self.order, part=self.part)
|
SalesOrderLineItem.objects.create(order=self.order, part=self.part)
|
||||||
|
|
||||||
def allocate_stock(self, full=True):
|
def allocate_stock(self, full=True):
|
||||||
|
|
||||||
# Allocate stock to the order
|
# Allocate stock to the order
|
||||||
SalesOrderAllocation.objects.create(
|
SalesOrderAllocation.objects.create(
|
||||||
line=self.line,
|
line=self.line,
|
||||||
item=StockItem.objects.get(pk=1),
|
item=StockItem.objects.get(pk=self.Sa.pk),
|
||||||
quantity=25)
|
quantity=25)
|
||||||
|
|
||||||
SalesOrderAllocation.objects.create(
|
SalesOrderAllocation.objects.create(
|
||||||
line=self.line,
|
line=self.line,
|
||||||
item=StockItem.objects.get(pk=2),
|
item=StockItem.objects.get(pk=self.Sb.pk),
|
||||||
quantity=25 if full else 20
|
quantity=25 if full else 20
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -119,15 +120,23 @@ class SalesOrderTest(TestCase):
|
|||||||
# There should now be 4 stock items
|
# There should now be 4 stock items
|
||||||
self.assertEqual(StockItem.objects.count(), 4)
|
self.assertEqual(StockItem.objects.count(), 4)
|
||||||
|
|
||||||
self.assertEqual(StockItem.objects.get(pk=1).quantity, 75)
|
Sa = StockItem.objects.get(pk=self.Sa.pk)
|
||||||
self.assertEqual(StockItem.objects.get(pk=2).quantity, 175)
|
Sb = StockItem.objects.get(pk=self.Sb.pk)
|
||||||
self.assertEqual(StockItem.objects.get(pk=3).quantity, 25)
|
|
||||||
self.assertEqual(StockItem.objects.get(pk=3).quantity, 25)
|
# 25 units subtracted from each of the original items
|
||||||
|
self.assertEqual(Sa.quantity, 75)
|
||||||
|
self.assertEqual(Sb.quantity, 175)
|
||||||
|
|
||||||
|
# And 2 items created which are associated with the order
|
||||||
|
outputs = StockItem.objects.filter(sales_order=self.order)
|
||||||
|
self.assertEqual(outputs.count(), 2)
|
||||||
|
|
||||||
|
for item in outputs.all():
|
||||||
|
self.assertEqual(item.quantity, 25)
|
||||||
|
|
||||||
|
|
||||||
self.assertEqual(StockItem.objects.get(pk=1).sales_order, None)
|
self.assertEqual(Sa.sales_order, None)
|
||||||
self.assertEqual(StockItem.objects.get(pk=2).sales_order, None)
|
self.assertEqual(Sb.sales_order, None)
|
||||||
self.assertEqual(StockItem.objects.get(pk=3).sales_order, self.order)
|
|
||||||
self.assertEqual(StockItem.objects.get(pk=4).sales_order, self.order)
|
|
||||||
|
|
||||||
# And no allocations
|
# And no allocations
|
||||||
self.assertEqual(SalesOrderAllocation.objects.count(), 0)
|
self.assertEqual(SalesOrderAllocation.objects.count(), 0)
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
# 10 x M2x4 LPHS
|
# 10 x M2x4 LPHS
|
||||||
- model: part.bomitem
|
- model: part.bomitem
|
||||||
|
pk: 1
|
||||||
fields:
|
fields:
|
||||||
part: 100
|
part: 100
|
||||||
sub_part: 1
|
sub_part: 1
|
||||||
@ -9,6 +10,7 @@
|
|||||||
|
|
||||||
# 40 x R_2K2_0805
|
# 40 x R_2K2_0805
|
||||||
- model: part.bomitem
|
- model: part.bomitem
|
||||||
|
pk: 2
|
||||||
fields:
|
fields:
|
||||||
part: 100
|
part: 100
|
||||||
sub_part: 3
|
sub_part: 3
|
||||||
@ -16,6 +18,7 @@
|
|||||||
|
|
||||||
# 25 x C_22N_0805
|
# 25 x C_22N_0805
|
||||||
- model: part.bomitem
|
- model: part.bomitem
|
||||||
|
pk: 3
|
||||||
fields:
|
fields:
|
||||||
part: 100
|
part: 100
|
||||||
sub_part: 5
|
sub_part: 5
|
||||||
@ -23,6 +26,7 @@
|
|||||||
|
|
||||||
# 3 x Orphan
|
# 3 x Orphan
|
||||||
- model: part.bomitem
|
- model: part.bomitem
|
||||||
|
pk: 4
|
||||||
fields:
|
fields:
|
||||||
part: 100
|
part: 100
|
||||||
sub_part: 50
|
sub_part: 50
|
||||||
|
@ -20,12 +20,14 @@
|
|||||||
|
|
||||||
# And some parameters (requires part.yaml)
|
# And some parameters (requires part.yaml)
|
||||||
- model: part.PartParameter
|
- model: part.PartParameter
|
||||||
|
pk: 1
|
||||||
fields:
|
fields:
|
||||||
part: 1
|
part: 1
|
||||||
template: 1
|
template: 1
|
||||||
data: 4
|
data: 4
|
||||||
|
|
||||||
- model: part.PartParameter
|
- model: part.PartParameter
|
||||||
|
pk: 2
|
||||||
fields:
|
fields:
|
||||||
part: 2
|
part: 2
|
||||||
template: 1
|
template: 1
|
||||||
|
@ -38,6 +38,7 @@
|
|||||||
|
|
||||||
|
|
||||||
- model: part.part
|
- model: part.part
|
||||||
|
pk: 4
|
||||||
fields:
|
fields:
|
||||||
name: 'R_4K7_0603'
|
name: 'R_4K7_0603'
|
||||||
description: '4.7kOhm resistor in 0603 package'
|
description: '4.7kOhm resistor in 0603 package'
|
||||||
@ -50,6 +51,7 @@
|
|||||||
|
|
||||||
# Create some capacitors
|
# Create some capacitors
|
||||||
- model: part.part
|
- model: part.part
|
||||||
|
pk: 5
|
||||||
fields:
|
fields:
|
||||||
name: 'C_22N_0805'
|
name: 'C_22N_0805'
|
||||||
description: '22nF capacitor in 0805 package'
|
description: '22nF capacitor in 0805 package'
|
||||||
|
@ -1,25 +1,30 @@
|
|||||||
# Tests for the top-level "chair" part
|
# Tests for the top-level "chair" part
|
||||||
- model: part.parttesttemplate
|
- model: part.parttesttemplate
|
||||||
|
pk: 1
|
||||||
fields:
|
fields:
|
||||||
part: 10000
|
part: 10000
|
||||||
test_name: Test strength of chair
|
test_name: Test strength of chair
|
||||||
|
|
||||||
- model: part.parttesttemplate
|
- model: part.parttesttemplate
|
||||||
|
pk: 2
|
||||||
fields:
|
fields:
|
||||||
part: 10000
|
part: 10000
|
||||||
test_name: Apply paint
|
test_name: Apply paint
|
||||||
|
|
||||||
- model: part.parttesttemplate
|
- model: part.parttesttemplate
|
||||||
|
pk: 3
|
||||||
fields:
|
fields:
|
||||||
part: 10000
|
part: 10000
|
||||||
test_name: Sew cushion
|
test_name: Sew cushion
|
||||||
|
|
||||||
- model: part.parttesttemplate
|
- model: part.parttesttemplate
|
||||||
|
pk: 4
|
||||||
fields:
|
fields:
|
||||||
part: 10000
|
part: 10000
|
||||||
test_name: Attach legs
|
test_name: Attach legs
|
||||||
|
|
||||||
- model: part.parttesttemplate
|
- model: part.parttesttemplate
|
||||||
|
pk: 5
|
||||||
fields:
|
fields:
|
||||||
part: 10000
|
part: 10000
|
||||||
test_name: Record weight
|
test_name: Record weight
|
||||||
@ -27,12 +32,14 @@
|
|||||||
|
|
||||||
# Add some tests for one of the variants
|
# Add some tests for one of the variants
|
||||||
- model: part.parttesttemplate
|
- model: part.parttesttemplate
|
||||||
|
pk: 6
|
||||||
fields:
|
fields:
|
||||||
part: 10003
|
part: 10003
|
||||||
test_name: Check that chair is green
|
test_name: Check that chair is green
|
||||||
required: true
|
required: true
|
||||||
|
|
||||||
- model: part.parttesttemplate
|
- model: part.parttesttemplate
|
||||||
|
pk: 7
|
||||||
fields:
|
fields:
|
||||||
part: 10004
|
part: 10004
|
||||||
test_name: Check that chair is especially green
|
test_name: Check that chair is especially green
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
# 4,000 screws in the dining room
|
# 4,000 screws in the dining room
|
||||||
- model: stock.stockitem
|
- model: stock.stockitem
|
||||||
|
pk: 1
|
||||||
fields:
|
fields:
|
||||||
part: 1
|
part: 1
|
||||||
location: 3
|
location: 3
|
||||||
@ -14,6 +15,7 @@
|
|||||||
|
|
||||||
# 5,000 screws in the bathroom
|
# 5,000 screws in the bathroom
|
||||||
- model: stock.stockitem
|
- model: stock.stockitem
|
||||||
|
pk: 2
|
||||||
fields:
|
fields:
|
||||||
part: 1
|
part: 1
|
||||||
location: 2
|
location: 2
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
- model: stock.stockitemtestresult
|
- model: stock.stockitemtestresult
|
||||||
|
pk: 1
|
||||||
fields:
|
fields:
|
||||||
stock_item: 105
|
stock_item: 105
|
||||||
test: "Firmware Version"
|
test: "Firmware Version"
|
||||||
@ -7,6 +8,7 @@
|
|||||||
date: 2020-02-02
|
date: 2020-02-02
|
||||||
|
|
||||||
- model: stock.stockitemtestresult
|
- model: stock.stockitemtestresult
|
||||||
|
pk: 2
|
||||||
fields:
|
fields:
|
||||||
stock_item: 105
|
stock_item: 105
|
||||||
test: "Settings Checksum"
|
test: "Settings Checksum"
|
||||||
@ -15,6 +17,7 @@
|
|||||||
date: 2020-02-02
|
date: 2020-02-02
|
||||||
|
|
||||||
- model: stock.stockitemtestresult
|
- model: stock.stockitemtestresult
|
||||||
|
pk: 3
|
||||||
fields:
|
fields:
|
||||||
stock_item: 105
|
stock_item: 105
|
||||||
test: "Temperature Test"
|
test: "Temperature Test"
|
||||||
@ -23,6 +26,7 @@
|
|||||||
notes: 'Got too hot or something'
|
notes: 'Got too hot or something'
|
||||||
|
|
||||||
- model: stock.stockitemtestresult
|
- model: stock.stockitemtestresult
|
||||||
|
pk: 4
|
||||||
fields:
|
fields:
|
||||||
stock_item: 105
|
stock_item: 105
|
||||||
test: "Temperature Test"
|
test: "Temperature Test"
|
||||||
@ -31,6 +35,7 @@
|
|||||||
notes: 'Passed temperature test by making it cooler'
|
notes: 'Passed temperature test by making it cooler'
|
||||||
|
|
||||||
- model: stock.stockitemtestresult
|
- model: stock.stockitemtestresult
|
||||||
|
pk: 5
|
||||||
fields:
|
fields:
|
||||||
stock_item: 522
|
stock_item: 522
|
||||||
test: 'applypaint'
|
test: 'applypaint'
|
||||||
@ -38,6 +43,7 @@
|
|||||||
date: 2020-05-17
|
date: 2020-05-17
|
||||||
|
|
||||||
- model: stock.stockitemtestresult
|
- model: stock.stockitemtestresult
|
||||||
|
pk: 6
|
||||||
fields:
|
fields:
|
||||||
stock_item: 522
|
stock_item: 522
|
||||||
test: 'applypaint'
|
test: 'applypaint'
|
||||||
@ -45,6 +51,7 @@
|
|||||||
date: 2020-05-18
|
date: 2020-05-18
|
||||||
|
|
||||||
- model: stock.stockitemtestresult
|
- model: stock.stockitemtestresult
|
||||||
|
pk: 7
|
||||||
fields:
|
fields:
|
||||||
stock_item: 522
|
stock_item: 522
|
||||||
test: 'Attach Legs'
|
test: 'Attach Legs'
|
||||||
@ -52,6 +59,7 @@
|
|||||||
date: 2020-05-17
|
date: 2020-05-17
|
||||||
|
|
||||||
- model: stock.stockitemtestresult
|
- model: stock.stockitemtestresult
|
||||||
|
pk: 8
|
||||||
fields:
|
fields:
|
||||||
stock_item: 522
|
stock_item: 522
|
||||||
test: 'Check that chair is GreEn '
|
test: 'Check that chair is GreEn '
|
||||||
|
@ -21,7 +21,7 @@ class StockAPITestCase(APITestCase):
|
|||||||
def setUp(self):
|
def setUp(self):
|
||||||
# Create a user for auth
|
# Create a user for auth
|
||||||
User = get_user_model()
|
User = get_user_model()
|
||||||
User.objects.create_user('testuser', 'test@testing.com', 'password')
|
self.user = User.objects.create_user('testuser', 'test@testing.com', 'password')
|
||||||
self.client.login(username='testuser', password='password')
|
self.client.login(username='testuser', password='password')
|
||||||
|
|
||||||
def doPost(self, url, data={}):
|
def doPost(self, url, data={}):
|
||||||
@ -308,4 +308,4 @@ class StockTestResultTest(StockAPITestCase):
|
|||||||
|
|
||||||
test = response.data[0]
|
test = response.data[0]
|
||||||
self.assertEqual(test['value'], '150kPa')
|
self.assertEqual(test['value'], '150kPa')
|
||||||
self.assertEqual(test['user'], 1)
|
self.assertEqual(test['user'], self.user.pk)
|
||||||
|
25
tasks.py
25
tasks.py
@ -174,37 +174,16 @@ def style(c):
|
|||||||
print("Running PEP style checks...")
|
print("Running PEP style checks...")
|
||||||
c.run('flake8 InvenTree')
|
c.run('flake8 InvenTree')
|
||||||
|
|
||||||
@task(help={'database': "Database framework to use (default=sqlite)"})
|
@task
|
||||||
def test(c, database=None):
|
def test(c, database=None):
|
||||||
"""
|
"""
|
||||||
Run unit-tests for InvenTree codebase.
|
Run unit-tests for InvenTree codebase.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if database is None:
|
|
||||||
database = 'sqlite'
|
|
||||||
|
|
||||||
database = database.lower()
|
|
||||||
|
|
||||||
allowed = {
|
|
||||||
'sqlite': 'InvenTree.settings',
|
|
||||||
'postgresql': 'InvenTree.ci_postgresql',
|
|
||||||
'mysql': 'InvenTree.ci_mysql',
|
|
||||||
}
|
|
||||||
|
|
||||||
if database not in allowed.keys():
|
|
||||||
print("Database framework not supported for testing:")
|
|
||||||
print("Choose from: '{a}'".format(a=allowed))
|
|
||||||
|
|
||||||
return False
|
|
||||||
|
|
||||||
# Run sanity check on the django install
|
# Run sanity check on the django install
|
||||||
manage(c, 'check')
|
manage(c, 'check')
|
||||||
|
|
||||||
# Run coverage tests
|
# Run coverage tests
|
||||||
manage(c, 'test {apps} --settings={sett}'.format(
|
manage(c, 'test', pty=True)
|
||||||
apps=' '.join(apps()),
|
|
||||||
sett=allowed[database]
|
|
||||||
))
|
|
||||||
|
|
||||||
@task
|
@task
|
||||||
def coverage(c):
|
def coverage(c):
|
||||||
|
Loading…
Reference in New Issue
Block a user