mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Unit test fixes
This commit is contained in:
parent
59341397ba
commit
c0ab2d1da9
@ -15,7 +15,7 @@ from datetime import datetime, timedelta
|
||||
from .models import Build
|
||||
from stock.models import StockItem
|
||||
|
||||
from InvenTree.status_codes import BuildStatus
|
||||
from InvenTree.status_codes import BuildStatus, StockStatus
|
||||
|
||||
|
||||
class BuildTestSimple(TestCase):
|
||||
@ -335,6 +335,7 @@ class TestBuildViews(TestCase):
|
||||
'confirm_incomplete': 1,
|
||||
'location': 1,
|
||||
'output': self.output.pk,
|
||||
'stock_status': StockStatus.DAMAGED
|
||||
},
|
||||
HTTP_X_REQUESTED_WITH='XMLHttpRequest'
|
||||
)
|
||||
@ -342,6 +343,7 @@ class TestBuildViews(TestCase):
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
data = json.loads(response.content)
|
||||
|
||||
self.assertTrue(data['form_valid'])
|
||||
|
||||
# Now the build should be able to be completed
|
||||
|
@ -449,6 +449,9 @@ class BuildOutputComplete(AjaxUpdateView):
|
||||
return form
|
||||
|
||||
def validate(self, build, form, **kwargs):
|
||||
"""
|
||||
Custom validation steps for the BuildOutputComplete" form
|
||||
"""
|
||||
|
||||
data = form.cleaned_data
|
||||
|
||||
@ -456,8 +459,14 @@ class BuildOutputComplete(AjaxUpdateView):
|
||||
|
||||
stock_status = data.get('stock_status', StockStatus.OK)
|
||||
|
||||
# Any "invalid" stock status defaults to OK
|
||||
try:
|
||||
stock_status = int(stock_status)
|
||||
except (ValueError):
|
||||
stock_status = StockStatus.OK
|
||||
|
||||
if int(stock_status) not in StockStatus.keys():
|
||||
form.add_error('status', _('Invalid stock status value selected'))
|
||||
form.add_error('stock_status', _('Invalid stock status value selected'))
|
||||
|
||||
if output:
|
||||
|
||||
@ -552,6 +561,12 @@ class BuildOutputComplete(AjaxUpdateView):
|
||||
output = data.get('output', None)
|
||||
stock_status = data.get('stock_status', StockStatus.OK)
|
||||
|
||||
# Any "invalid" stock status defaults to OK
|
||||
try:
|
||||
stock_status = int(stock_status)
|
||||
except (ValueError):
|
||||
stock_status = StockStatus.OK
|
||||
|
||||
# Complete the build output
|
||||
build.completeBuildOutput(
|
||||
output,
|
||||
|
Binary file not shown.
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
BIN
InvenTree/locale/fr/LC_MESSAGES/django.mo
Normal file
BIN
InvenTree/locale/fr/LC_MESSAGES/django.mo
Normal file
Binary file not shown.
File diff suppressed because it is too large
Load Diff
BIN
InvenTree/locale/it/LC_MESSAGES/django.mo
Normal file
BIN
InvenTree/locale/it/LC_MESSAGES/django.mo
Normal file
Binary file not shown.
File diff suppressed because it is too large
Load Diff
BIN
InvenTree/locale/ja/LC_MESSAGES/django.mo
Normal file
BIN
InvenTree/locale/ja/LC_MESSAGES/django.mo
Normal file
Binary file not shown.
File diff suppressed because it is too large
Load Diff
BIN
InvenTree/locale/pl/LC_MESSAGES/django.mo
Normal file
BIN
InvenTree/locale/pl/LC_MESSAGES/django.mo
Normal file
Binary file not shown.
File diff suppressed because it is too large
Load Diff
BIN
InvenTree/locale/ru/LC_MESSAGES/django.mo
Normal file
BIN
InvenTree/locale/ru/LC_MESSAGES/django.mo
Normal file
Binary file not shown.
File diff suppressed because it is too large
Load Diff
BIN
InvenTree/locale/zh/LC_MESSAGES/django.mo
Normal file
BIN
InvenTree/locale/zh/LC_MESSAGES/django.mo
Normal file
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user