def validate_claim_code(self, field): try: claiming.unpack_claim_code(field.data) except claiming.InvalidClaimCode: raise wtforms.validators.ValidationError( "`{}` doesn't look like a valid claim code :(".format(field.data) )
def test_encoding(self): for cc, device, secret in CC_TEST_VECTORS: self.assertEqual(claiming.encode(device, secret), cc) dec_device, dec_secret, _, _ = claiming.unpack_claim_code(cc) self.assertEqual(dec_device, device) self.assertEqual(dec_secret, secret)
def validate_claim_code(self, field): try: claiming.unpack_claim_code(field.data) except claiming.InvalidClaimCode: raise wtforms.validators.ValidationError("`{}` doesn't look like a valid claim code :(".format(field.data))