Пример #1
0
 def test_invalid_cert_list_rejected(self):
     """
     Cert list rejected if not a spaceless comma delimited list of integers
     """
     self.form_kwargs.update({'cert_list': 'US1,US2'})
     form = CertificateRegisterForm(self.form_kwargs)
     self.assertFalse(form.is_valid())
Пример #2
0
 def test_dupe_certificate_invalid(self):
     """
     Validation fails when requested certificates already exist
     """
     mommy.make(Certificate, number=1)
     form = CertificateRegisterForm(self.form_kwargs)
     self.assertFalse(form.is_valid())
Пример #3
0
 def test_dupe_requested_certificate_invalid(self):
     """
     Validation fails when requested certificates contain duplicates
     """
     self.form_kwargs.update({'cert_list': '1,1'})
     form = CertificateRegisterForm(self.form_kwargs)
     self.assertFalse(form.is_valid())
Пример #4
0
 def test_validation_fails_if_licensee_inactive(self):
     """Fail validation if licensee not active"""
     self.licensee.is_active = False
     self.licensee.save()
     form = CertificateRegisterForm(self.form_kwargs)
     valid = form.is_valid()
     self.assertFalse(valid)
Пример #5
0
 def test_id_ranges_must_be_valid(self):
     """cert_from is less than or equal to cert_to"""
     self._make_sequential(25, 10)
     form = CertificateRegisterForm(self.form_kwargs)
     valid = form.is_valid()
     self.assertIn("Certificate 'To' value must be greater than or equal to 'From' value.",
                   [e.message for e in form.non_field_errors().data])
     self.assertFalse(valid)
Пример #6
0
 def test_id_list_required_if_method_is_list(self):
     """Reject w/ message if cert_list isn't populated but List method is selected"""
     self.form_kwargs.pop('cert_list')
     form = CertificateRegisterForm(self.form_kwargs)
     valid = form.is_valid()
     self.assertIn("Certificate List must be provided when List method is selected.",
                   [e.message for e in form.non_field_errors().data])
     self.assertFalse(valid)
Пример #7
0
 def test_validation_fails_if_licensee_and_contact_dont_match(self):
     """Fail validation and provide msg if provided user is not associated with licensee"""
     self.user.profile.licensees.remove(self.licensee.id)
     form = CertificateRegisterForm(self.form_kwargs)
     valid = form.is_valid()
     self.assertIn('Contact is not associated with selected Licensee',
                   [e.message for e in form.non_field_errors().data])
     self.assertFalse(valid)
Пример #8
0
 def test_id_range_required_if_method_is_sequential(self):
     """
         Reject w/ message if cert_to & cert_from are not
         populated but sequential method is selected
     """
     self.form_kwargs.pop('cert_list')
     self.form_kwargs['registration_method'] = 'sequential'
     form = CertificateRegisterForm(self.form_kwargs)
     valid = form.is_valid()
     self.assertIn("Certificate To and From must be provided when Sequential method is selected.",
                   [e.message for e in form.non_field_errors().data])
     self.assertFalse(valid)
Пример #9
0
 def test_parse_list(self):
     """List of integers returned from incoming string"""
     form = CertificateRegisterForm(self.form_kwargs)
     form.is_valid()
     self.assertEqual(form.get_cert_list(), [1])
Пример #10
0
 def test_parse_sequential(self):
     """List of sequential integers generated from provided start/end points"""
     self._make_sequential(1, 3)
     form = CertificateRegisterForm(self.form_kwargs)
     form.is_valid()
     self.assertEqual(form.get_cert_list(), [1, 2, 3])
Пример #11
0
 def test_valid_form_no_errors_sequential(self):
     """Form validates w/ sequential data"""
     form = CertificateRegisterForm(self.form_kwargs)
     self._make_sequential(1, 2)
     valid = form.is_valid()
     self.assertTrue(valid)
Пример #12
0
 def test_valid_form_no_errors_list(self):
     """Form validates w/ list data"""
     form = CertificateRegisterForm(self.form_kwargs)
     valid = form.is_valid()
     self.assertTrue(valid)
Пример #13
0
 def test_valid_form_no_errors_sequential(self):
     """Form validates w/ sequential data"""
     self.form_kwargs['payment_amount'] = 40
     form = CertificateRegisterForm(self.form_kwargs)
     self._make_sequential(1, 2)
     self.assertTrue(form.is_valid())
Пример #14
0
 def test_payment_not_expected_amount(self):
     """Payment must be # of certs * Certificate.PRICE"""
     self.form_kwargs['payment_amount'] = 1
     form = CertificateRegisterForm(self.form_kwargs)
     self.assertFalse(form.is_valid())