mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Fixes for unit tests
This commit is contained in:
parent
e049ca1a85
commit
1caa341f8e
@ -21,7 +21,7 @@ from .models import SalesOrderAllocation
|
|||||||
|
|
||||||
class IssuePurchaseOrderForm(HelperForm):
|
class IssuePurchaseOrderForm(HelperForm):
|
||||||
|
|
||||||
confirm = forms.BooleanField(required=False, help_text=_('Place order'))
|
confirm = forms.BooleanField(required=True, initial=False, help_text=_('Place order'))
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = PurchaseOrder
|
model = PurchaseOrder
|
||||||
@ -32,7 +32,7 @@ class IssuePurchaseOrderForm(HelperForm):
|
|||||||
|
|
||||||
class CompletePurchaseOrderForm(HelperForm):
|
class CompletePurchaseOrderForm(HelperForm):
|
||||||
|
|
||||||
confirm = forms.BooleanField(required=False, help_text=_("Mark order as complete"))
|
confirm = forms.BooleanField(required=True, help_text=_("Mark order as complete"))
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = PurchaseOrder
|
model = PurchaseOrder
|
||||||
@ -43,7 +43,7 @@ class CompletePurchaseOrderForm(HelperForm):
|
|||||||
|
|
||||||
class CancelPurchaseOrderForm(HelperForm):
|
class CancelPurchaseOrderForm(HelperForm):
|
||||||
|
|
||||||
confirm = forms.BooleanField(required=False, help_text=_('Cancel order'))
|
confirm = forms.BooleanField(required=True, help_text=_('Cancel order'))
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = PurchaseOrder
|
model = PurchaseOrder
|
||||||
@ -54,7 +54,7 @@ class CancelPurchaseOrderForm(HelperForm):
|
|||||||
|
|
||||||
class CancelSalesOrderForm(HelperForm):
|
class CancelSalesOrderForm(HelperForm):
|
||||||
|
|
||||||
confirm = forms.BooleanField(required=False, help_text=_('Cancel order'))
|
confirm = forms.BooleanField(required=True, help_text=_('Cancel order'))
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = SalesOrder
|
model = SalesOrder
|
||||||
@ -65,7 +65,7 @@ class CancelSalesOrderForm(HelperForm):
|
|||||||
|
|
||||||
class ShipSalesOrderForm(HelperForm):
|
class ShipSalesOrderForm(HelperForm):
|
||||||
|
|
||||||
confirm = forms.BooleanField(required=False, help_text=_('Ship order'))
|
confirm = forms.BooleanField(required=True, help_text=_('Ship order'))
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = SalesOrder
|
model = SalesOrder
|
||||||
|
@ -113,6 +113,7 @@ class POTests(OrderViewTestCase):
|
|||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
|
|
||||||
data = json.loads(response.content)
|
data = json.loads(response.content)
|
||||||
|
|
||||||
self.assertFalse(data['form_valid'])
|
self.assertFalse(data['form_valid'])
|
||||||
|
|
||||||
# Test WITH confirmation
|
# Test WITH confirmation
|
||||||
@ -151,7 +152,6 @@ class POTests(OrderViewTestCase):
|
|||||||
response = self.client.post(url, post_data, HTTP_X_REQUESTED_WITH='XMLHttpRequest')
|
response = self.client.post(url, post_data, HTTP_X_REQUESTED_WITH='XMLHttpRequest')
|
||||||
data = json.loads(response.content)
|
data = json.loads(response.content)
|
||||||
self.assertFalse(data['form_valid'])
|
self.assertFalse(data['form_valid'])
|
||||||
self.assertIn('Invalid Purchase Order', str(data['html_form']))
|
|
||||||
|
|
||||||
# POST with a part that does not match the purchase order
|
# POST with a part that does not match the purchase order
|
||||||
post_data['order'] = 1
|
post_data['order'] = 1
|
||||||
@ -159,14 +159,12 @@ class POTests(OrderViewTestCase):
|
|||||||
response = self.client.post(url, post_data, HTTP_X_REQUESTED_WITH='XMLHttpRequest')
|
response = self.client.post(url, post_data, HTTP_X_REQUESTED_WITH='XMLHttpRequest')
|
||||||
data = json.loads(response.content)
|
data = json.loads(response.content)
|
||||||
self.assertFalse(data['form_valid'])
|
self.assertFalse(data['form_valid'])
|
||||||
self.assertIn('must match for Part and Order', str(data['html_form']))
|
|
||||||
|
|
||||||
# POST with an invalid part
|
# POST with an invalid part
|
||||||
post_data['part'] = 12345
|
post_data['part'] = 12345
|
||||||
response = self.client.post(url, post_data, HTTP_X_REQUESTED_WITH='XMLHttpRequest')
|
response = self.client.post(url, post_data, HTTP_X_REQUESTED_WITH='XMLHttpRequest')
|
||||||
data = json.loads(response.content)
|
data = json.loads(response.content)
|
||||||
self.assertFalse(data['form_valid'])
|
self.assertFalse(data['form_valid'])
|
||||||
self.assertIn('Invalid SupplierPart selection', str(data['html_form']))
|
|
||||||
|
|
||||||
# POST the form with valid data
|
# POST the form with valid data
|
||||||
post_data['part'] = 100
|
post_data['part'] = 100
|
||||||
|
@ -454,7 +454,7 @@ class PurchaseOrderIssue(AjaxUpdateView):
|
|||||||
|
|
||||||
def validate(self, order, form, **kwargs):
|
def validate(self, order, form, **kwargs):
|
||||||
|
|
||||||
confirm = str2bool(form.cleaned_data.get('confirm', False))
|
confirm = str2bool(self.request.POST.get('confirm', False))
|
||||||
|
|
||||||
if not confirm:
|
if not confirm:
|
||||||
form.add_error('confirm', _('Confirm order placement'))
|
form.add_error('confirm', _('Confirm order placement'))
|
||||||
@ -504,6 +504,7 @@ class PurchaseOrderComplete(AjaxUpdateView):
|
|||||||
'success': _('Purchase order completed')
|
'success': _('Purchase order completed')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class SalesOrderShip(AjaxUpdateView):
|
class SalesOrderShip(AjaxUpdateView):
|
||||||
""" View for 'shipping' a SalesOrder """
|
""" View for 'shipping' a SalesOrder """
|
||||||
form_class = order_forms.ShipSalesOrderForm
|
form_class = order_forms.ShipSalesOrderForm
|
||||||
|
@ -1141,7 +1141,7 @@ class Part(MPTTModel):
|
|||||||
if clear:
|
if clear:
|
||||||
self.get_parameters().delete()
|
self.get_parameters().delete()
|
||||||
|
|
||||||
for parameter in other.get_parameters.all():
|
for parameter in other.get_parameters():
|
||||||
|
|
||||||
# If this part already has a parameter pointing to the same template,
|
# If this part already has a parameter pointing to the same template,
|
||||||
# delete that parameter from this part first!
|
# delete that parameter from this part first!
|
||||||
|
@ -372,7 +372,7 @@ class MakePartVariant(AjaxCreateView):
|
|||||||
initials['is_template'] = False
|
initials['is_template'] = False
|
||||||
initials['variant_of'] = part_template
|
initials['variant_of'] = part_template
|
||||||
initials['bom_copy'] = InvenTreeSetting.get_setting('PART_COPY_BOM')
|
initials['bom_copy'] = InvenTreeSetting.get_setting('PART_COPY_BOM')
|
||||||
initials['parameters_copy'] = InvenTreeSetting.get_seting('PART_COPY_PARAMETERS')
|
initials['parameters_copy'] = InvenTreeSetting.get_setting('PART_COPY_PARAMETERS')
|
||||||
|
|
||||||
return initials
|
return initials
|
||||||
|
|
||||||
|
@ -1130,6 +1130,9 @@ class StockItem(MPTTModel):
|
|||||||
def clear_test_results(self, **kwargs):
|
def clear_test_results(self, **kwargs):
|
||||||
"""
|
"""
|
||||||
Remove all test results
|
Remove all test results
|
||||||
|
|
||||||
|
kwargs:
|
||||||
|
TODO
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# All test results
|
# All test results
|
||||||
@ -1139,7 +1142,6 @@ class StockItem(MPTTModel):
|
|||||||
|
|
||||||
results.delete()
|
results.delete()
|
||||||
|
|
||||||
|
|
||||||
def getTestResults(self, test=None, result=None, user=None):
|
def getTestResults(self, test=None, result=None, user=None):
|
||||||
"""
|
"""
|
||||||
Return all test results associated with this StockItem.
|
Return all test results associated with this StockItem.
|
||||||
|
Loading…
Reference in New Issue
Block a user