# Path: prestans/exception.py
# class Base(Exception):
# class UnsupportedVocabularyError(Base):
# class UnsupportedContentTypeError(Base):
# class ValidationError(Base):
# class HandlerException(Base):
# class RequestException(HandlerException):
# class ResponseException(HandlerException):
# class UnimplementedVerbError(RequestException):
# class NoEndpointError(RequestException):
# class AuthenticationError(RequestException):
# class AuthorizationError(RequestException):
# class SerializationFailedError(RequestException):
# class DeSerializationFailedError(RequestException):
# class AttributeFilterDiffers(RequestException):
# class InconsistentPersistentDataError(Base):
# class DataValidationException(Base):
# class RequiredAttributeError(DataValidationException):
# class ParseFailedError(DataValidationException):
# class LessThanMinimumError(DataValidationException):
# class MoreThanMaximumError(DataValidationException):
# class InvalidChoiceError(DataValidationException):
# class MinimumLengthError(DataValidationException):
# class MaximumLengthError(DataValidationException):
# class InvalidTypeError(DataValidationException):
# class MissingParameterError(DataValidationException):
# class InvalidFormatError(DataValidationException):
# class InvalidMetaValueError(DataValidationException):
# class UnregisteredAdapterError(DataValidationException):
# class ServiceUnavailable(ResponseException):
# class BadRequest(ResponseException):
# class Conflict(ResponseException):
# class NotFound(ResponseException):
# class Unauthorized(ResponseException):
# class MovedPermanently(ResponseException):
# class Redirect(ResponseException):
# class TemporaryRedirect(Redirect):
# class PermanentRedirect(Redirect):
# class PaymentRequired(ResponseException):
# class Forbidden(ResponseException):
# class InternalServerError(ResponseException):
#     def __init__(self, http_status, message):
#     def http_status(self):
#     def http_status(self, value):
#     def stack_trace(self):
#     def push_trace(self, trace_object):
#     def message(self):
#     def __str__(self):
#     def __init__(self, accept_header, supported_types):
#     def __init__(self, requested_mime_type, content_type):
#     def __init__(self, message, attribute_name, value, blueprint):
#     def append_validation_trace(self, blueprint):
#     def __str__(self):
#     def __init__(self, code, message):
#     def request(self):
#     def request(self, value):
#     def log_message(self):
#     def __str__(self):
#     def __init__(self, code, message):
#     def __init__(self, code, message, response_model=None):
#     def response_model(self):
#     def __init__(self, verb_name):
#     def __init__(self):
#     def __init__(self, message=None):
#     def __init__(self, role_name):
#     def __init__(self, format):
#     def __init__(self, format):
#     def __init__(self, attribute_list):
#     def __init__(self, attribute_name, exception_message):
#     def __str__(self):
#     def __init__(self, message):
#     def __init__(self):
#     def __init__(self, message="Parser Failed"):
#     def __init__(self, value, allowed_min):
#     def __init__(self, value, allowed_max):
#     def __init__(self, value, allowed_choices):
#     def __init__(self, value, minimum):
#     def __init__(self, value, maximum):
#     def __init__(self, value, type_name):
#     def __init__(self):
#     def __init__(self, value):
#     def __init__(self):
#     def __init__(self, model_name):
#     def __init__(self, message="Service Unavailable", response_model=None):
#     def __init__(self, message="Bad Request", response_model=None):
#     def __init__(self, message="Conflict", response_model=None):
#     def __init__(self, message="Not Found", response_model=None):
#     def __init__(self, message="Unauthorized", response_model=None):
#     def __init__(self, message="Moved Permanently", response_model=None):
#     def __init__(self, code, url):
#     def url(self):
#     def __init__(self, url):
#     def __init__(self, url):
#     def __init__(self, message="Payment Required", response_model=None):
#     def __init__(self, message="Forbidden", response_model=None):
#     def __init__(self, message="Internal Server Error", response_model=None):
# 
# Path: prestans/types/boolean.py
# class Boolean(DataType):
# 
#     def __init__(self, default=None, required=True, description=None):
# 
#         if default is None or \
#            isinstance(default, bool):
#             self._default = default
#         else:
#             raise TypeError("default must be of type bool or None")
#         self._required = required
#         self._description = description
# 
#     @property
#     def required(self):
#         return self._required
# 
#     @property
#     def default(self):
#         return self._default
# 
#     @property
#     def description(self):
#         return self._description
# 
#     def blueprint(self):
# 
#         blueprint = dict()
#         blueprint['type'] = 'boolean'
# 
#         constraints = dict()
#         constraints['default'] = self.default
#         constraints['required'] = self.required
#         constraints['description'] = self.description
# 
#         blueprint['constraints'] = constraints
#         return blueprint
# 
#     def validate(self, value):
# 
#         if not self._required and self._default is None and value is None:
#             return None
#         elif self._required and self._default is None and value is None:
#             raise exception.RequiredAttributeError()
#         elif value is None and self.default is not None:
#             value = self._default
# 
#         if not isinstance(value, bool):
#             raise exception.ParseFailedError()
# 
#         return value


import unittest
from prestans import exception
from prestans.types import Boolean



class BooleanUnitTest(unittest.TestCase):

    def test_required(self):
        required_default = Boolean()
        self.assertEqual(required_default.required, True)

        required_true = Boolean(required=True)
        self.assertEqual(required_true.required, True)


# Path: prestans/exception.py
# class Base(Exception):
# class UnsupportedVocabularyError(Base):
# class UnsupportedContentTypeError(Base):
# class ValidationError(Base):
# class HandlerException(Base):
# class RequestException(HandlerException):
# class ResponseException(HandlerException):
# class UnimplementedVerbError(RequestException):
# class NoEndpointError(RequestException):
# class AuthenticationError(RequestException):
# class AuthorizationError(RequestException):
# class SerializationFailedError(RequestException):
# class DeSerializationFailedError(RequestException):
# class AttributeFilterDiffers(RequestException):
# class InconsistentPersistentDataError(Base):
# class DataValidationException(Base):
# class RequiredAttributeError(DataValidationException):
# class ParseFailedError(DataValidationException):
# class LessThanMinimumError(DataValidationException):
# class MoreThanMaximumError(DataValidationException):
# class InvalidChoiceError(DataValidationException):
# class MinimumLengthError(DataValidationException):
# class MaximumLengthError(DataValidationException):
# class InvalidTypeError(DataValidationException):
# class MissingParameterError(DataValidationException):
# class InvalidFormatError(DataValidationException):
# class InvalidMetaValueError(DataValidationException):
# class UnregisteredAdapterError(DataValidationException):
# class ServiceUnavailable(ResponseException):
# class BadRequest(ResponseException):
# class Conflict(ResponseException):
# class NotFound(ResponseException):
# class Unauthorized(ResponseException):
# class MovedPermanently(ResponseException):
# class Redirect(ResponseException):
# class TemporaryRedirect(Redirect):
# class PermanentRedirect(Redirect):
# class PaymentRequired(ResponseException):
# class Forbidden(ResponseException):
# class InternalServerError(ResponseException):
#     def __init__(self, http_status, message):
#     def http_status(self):
#     def http_status(self, value):
#     def stack_trace(self):
#     def push_trace(self, trace_object):
#     def message(self):
#     def __str__(self):
#     def __init__(self, accept_header, supported_types):
#     def __init__(self, requested_mime_type, content_type):
#     def __init__(self, message, attribute_name, value, blueprint):
#     def append_validation_trace(self, blueprint):
#     def __str__(self):
#     def __init__(self, code, message):
#     def request(self):
#     def request(self, value):
#     def log_message(self):
#     def __str__(self):
#     def __init__(self, code, message):
#     def __init__(self, code, message, response_model=None):
#     def response_model(self):
#     def __init__(self, verb_name):
#     def __init__(self):
#     def __init__(self, message=None):
#     def __init__(self, role_name):
#     def __init__(self, format):
#     def __init__(self, format):
#     def __init__(self, attribute_list):
#     def __init__(self, attribute_name, exception_message):
#     def __str__(self):
#     def __init__(self, message):
#     def __init__(self):
#     def __init__(self, message="Parser Failed"):
#     def __init__(self, value, allowed_min):
#     def __init__(self, value, allowed_max):
#     def __init__(self, value, allowed_choices):
#     def __init__(self, value, minimum):
#     def __init__(self, value, maximum):
#     def __init__(self, value, type_name):
#     def __init__(self):
#     def __init__(self, value):
#     def __init__(self):
#     def __init__(self, model_name):
#     def __init__(self, message="Service Unavailable", response_model=None):
#     def __init__(self, message="Bad Request", response_model=None):
#     def __init__(self, message="Conflict", response_model=None):
#     def __init__(self, message="Not Found", response_model=None):
#     def __init__(self, message="Unauthorized", response_model=None):
#     def __init__(self, message="Moved Permanently", response_model=None):
#     def __init__(self, code, url):
#     def url(self):
#     def __init__(self, url):
#     def __init__(self, url):
#     def __init__(self, message="Payment Required", response_model=None):
#     def __init__(self, message="Forbidden", response_model=None):
#     def __init__(self, message="Internal Server Error", response_model=None):
# 
# Path: prestans/types/boolean.py
# class Boolean(DataType):
# 
#     def __init__(self, default=None, required=True, description=None):
# 
#         if default is None or \
#            isinstance(default, bool):
#             self._default = default
#         else:
#             raise TypeError("default must be of type bool or None")
#         self._required = required
#         self._description = description
# 
#     @property
#     def required(self):
#         return self._required
# 
#     @property
#     def default(self):
#         return self._default
# 
#     @property
#     def description(self):
#         return self._description
# 
#     def blueprint(self):
# 
#         blueprint = dict()
#         blueprint['type'] = 'boolean'
# 
#         constraints = dict()
#         constraints['default'] = self.default
#         constraints['required'] = self.required
#         constraints['description'] = self.description
# 
#         blueprint['constraints'] = constraints
#         return blueprint
# 
#     def validate(self, value):
# 
#         if not self._required and self._default is None and value is None:
#             return None
#         elif self._required and self._default is None and value is None:
#             raise exception.RequiredAttributeError()
#         elif value is None and self.default is not None:
#             value = self._default
# 
#         if not isinstance(value, bool):
#             raise exception.ParseFailedError()
# 
#         return value


# Path: tests/types/test_boolean.py
import unittest
from prestans import exception
from prestans.types import Boolean




class BooleanUnitTest(unittest.TestCase):

    def test_required(self):
        required_default = Boolean()
        self.assertEqual(required_default.required, True)

        required_true = Boolean(required=True)
        self.assertEqual(required_true.required, True)


        required_false = Boolean(required=False)