You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

voucher_form_tests.py 960B

123456789101112131415161718192021222324252627282930
  1. from django import test
  2. from oscar.apps.dashboard.vouchers import forms
  3. class TestVoucherForm(test.TestCase):
  4. def test_doesnt_crash_on_empty_date_fields(self):
  5. """
  6. There was a bug fixed in 02b3644 where the voucher form would raise an
  7. exception (instead of just failing validation) when being called with
  8. empty fields. This tests exists to prevent a regression.
  9. """
  10. data = {
  11. 'code': '',
  12. 'name': '',
  13. 'start_date': '',
  14. 'end_date': '',
  15. 'benefit_range': '',
  16. 'benefit_type': 'Percentage',
  17. 'usage': 'Single use',
  18. }
  19. form = forms.VoucherForm(data=data)
  20. try:
  21. form.is_valid()
  22. except Exception as e:
  23. import traceback
  24. self.fail(
  25. "Exception raised while validating voucher form: %s\n\n%s" % (
  26. e.message, traceback.format_exc()))