Add unit test to check an "empty" (null) barcode can be supplied

This commit is contained in:
Oliver 2021-11-09 12:07:57 +11:00
parent 1520c296dd
commit 30684685f9
2 changed files with 26 additions and 0 deletions

View File

@ -242,6 +242,7 @@ class POLineItemReceiveSerializer(serializers.Serializer):
help_text=_('Unique identifier field'),
default='',
required=False,
allow_null=True,
allow_blank=True,
)

View File

@ -349,6 +349,31 @@ class PurchaseOrderReceiveTest(OrderTest):
# No new stock items have been created
self.assertEqual(self.n, StockItem.objects.count())
def test_null_barcode(self):
"""
Test than a "null" barcode field can be provided
"""
# Set stock item barcode
item = StockItem.objects.get(pk=1)
item.save()
# Test with "null" value
self.post(
self.url,
{
'items': [
{
'line_item': 1,
'quantity': 50,
'barcode': None,
}
],
'location': 1,
},
expected_code=201
)
def test_invalid_barcodes(self):
"""
Tests for checking in items with invalid barcodes: