mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Unit tests for downloading BuildOrder data
This commit is contained in:
parent
0d078768fe
commit
c5b14944a1
@ -16,7 +16,7 @@ class BuildResource(ModelResource):
|
||||
# but we don't for other ones.
|
||||
# TODO: 2022-05-12 - Need to investigate why this is the case!
|
||||
|
||||
pk = Field(attribute='pk')
|
||||
id = Field(attribute='pk')
|
||||
|
||||
reference = Field(attribute='reference')
|
||||
|
||||
@ -45,6 +45,7 @@ class BuildResource(ModelResource):
|
||||
clean_model_instances = True
|
||||
exclude = [
|
||||
'lft', 'rght', 'tree_id', 'level',
|
||||
'metadata',
|
||||
]
|
||||
|
||||
|
||||
|
@ -511,6 +511,50 @@ class BuildTest(BuildAPITest):
|
||||
|
||||
self.assertIn('This build output has already been completed', str(response.data))
|
||||
|
||||
def test_download_build_orders(self):
|
||||
|
||||
required_cols = [
|
||||
'reference',
|
||||
'status',
|
||||
'completed',
|
||||
'batch',
|
||||
'notes',
|
||||
'title',
|
||||
'part',
|
||||
'part_name',
|
||||
'id',
|
||||
'quantity',
|
||||
]
|
||||
|
||||
excluded_cols = [
|
||||
'lft', 'rght', 'tree_id', 'level',
|
||||
'metadata',
|
||||
]
|
||||
|
||||
with self.download_file(
|
||||
reverse('api-build-list'),
|
||||
{
|
||||
'export': 'csv',
|
||||
}
|
||||
) as fo:
|
||||
|
||||
data = self.process_csv(
|
||||
fo,
|
||||
required_cols=required_cols,
|
||||
excluded_cols=excluded_cols,
|
||||
required_rows=Build.objects.count()
|
||||
)
|
||||
|
||||
for row in data:
|
||||
|
||||
build = Build.objects.get(pk=row['id'])
|
||||
|
||||
self.assertEqual(str(build.part.pk), row['part'])
|
||||
self.assertEqual(build.part.full_name, row['part_name'])
|
||||
|
||||
self.assertEqual(build.reference, row['reference'])
|
||||
self.assertEqual(build.title, row['title'])
|
||||
|
||||
|
||||
class BuildAllocationTest(BuildAPITest):
|
||||
"""
|
||||
|
@ -381,6 +381,7 @@ class PurchaseOrderDownloadTest(OrderTest):
|
||||
self.assertEqual(order.description, row['description'])
|
||||
self.assertEqual(order.reference, row['reference'])
|
||||
|
||||
|
||||
class PurchaseOrderReceiveTest(OrderTest):
|
||||
"""
|
||||
Unit tests for receiving items against a PurchaseOrder
|
||||
|
Loading…
Reference in New Issue
Block a user