예제 #1
0
 def test_cert_id_value_0_valid_in_debug_mode(self):
     data = {'cert_id': '0'}
     form = forms.IARCV2ExistingCertificateForm(data=data, app=self.app)
     eq_(form.is_valid(), True)
     eq_(form.errors, {})
     eq_(form.cleaned_data['cert_id'], None)  # Will be handled by save().
     return form
예제 #2
0
 def test_cert_id_valid_uuid_no_separators(self):
     cert = uuid.uuid4()
     data = {'cert_id': cert.get_hex()}
     form = forms.IARCV2ExistingCertificateForm(data=data, app=self.app)
     eq_(form.is_valid(), True)
     eq_(form.errors, {})
     eq_(form.cleaned_data['cert_id'], unicode(cert))
예제 #3
0
    def test_cert_id_valid_uuid_no_separators_already_used(self):
        cert = uuid.uuid4()
        data = {'cert_id': cert.get_hex()}
        # If another app is using this cert, the form should be invalid.
        iarc_cert = IARCCert.objects.create(app=app_factory(), cert_id=cert)
        form = forms.IARCV2ExistingCertificateForm(data=data, app=self.app)
        eq_(form.is_valid(), False)
        eq_(form.errors['cert_id'], [
            'This IARC certificate is already being used for another '
            'app. Please create a new IARC Ratings Certificate.'
        ])

        # If the cert is used by the same app, then it should be valid:
        iarc_cert.update(app=self.app)
        form = forms.IARCV2ExistingCertificateForm(data=data, app=self.app)
        eq_(form.is_valid(), True)
        eq_(form.cleaned_data['cert_id'], unicode(cert))
예제 #4
0
 def test_cert_id_invalid(self):
     data = {'cert_id': 'garbage'}
     form = forms.IARCV2ExistingCertificateForm(data=data, app=self.app)
     eq_(form.is_valid(), False)
     eq_(form.errors['cert_id'], ['badly formed hexadecimal UUID string'])
     return form
예제 #5
0
 def test_cert_id_required(self):
     data = {}
     form = forms.IARCV2ExistingCertificateForm(data=data, app=self.app)
     eq_(form.is_valid(), False)
     eq_(form.errors['cert_id'], ['This field is required.'])