# Path: libcloud_rest/api/validators.py
# class BaseValidator(object):
# class NumericValidator(BaseValidator):
# class IntegerValidator(NumericValidator):
# class FloatValidator(NumericValidator):
# class StringValidator(BaseValidator):
# class BooleanValidator(BaseValidator):
# class NoneValidator(BaseValidator):
# class ConstValidator(BaseValidator):
# class DictValidator(BaseValidator):
# class ChoicesValidator(BaseValidator):
# class TypeValidator(BaseValidator):
#     def __init__(self, *args, **kwargs):
#     def configure(self, args, kwargs):
#     def _get_name(self):
#     def _set_name(self, new_name):
#     def __call__(self, data):
#     def _validate(self):
#     def _check_data(self):
#     def configure(self, args, kwargs):
#     def _check_data(self):
#     def _check_data(self):
#     def _check_data(self):
#     def _check_data(self):
#     def configure(self, args, kwargs):
#     def _check_data(self):
#     def configure(self, args, kwargs):
#     def _check_data(self):
#     def configure(self, args, kwargs):
#     def _check_data(self):
#     def configure(self, args, kwargs):
#     def _check_data(self):


import unittest2
from libcloud_rest.api import validators
from libcloud_rest.errors import ValidationError, MissingArguments,\
    UnknownArgument
        invalid_integer = '12.3'
        self.assertTrue(integer_validator(valid_integer))
        self.assertTrue(integer_validator(valid_integer2))
        self.assertRaises(ValidationError, integer_validator, invalid_integer)
        #test max and min
        max_int_validator = validators.IntegerValidator(max=100, min=0)
        valid_integer = 50
        invalid_integer = -1
        invalid_integer2 = 101
        self.assertTrue(max_int_validator(valid_integer))
        self.assertRaises(ValidationError, max_int_validator, invalid_integer)
        self.assertRaises(ValidationError, max_int_validator, invalid_integer2)

    def test_dict(self):
        dict_validator = validators.DictValidator(
            {'arg1': validators.StringValidator()})
        valid_dict = {'arg1': 'str'}
        invalid_dict = {'arg1': 123}
        invalid_dict2 = {'abc': 'str'}
        self.assertTrue(dict_validator(valid_dict))
        self.assertRaises(ValidationError, dict_validator, invalid_dict)
        self.assertRaises(ValidationError, dict_validator, invalid_dict2)

    def test_required(self):
        req_string_validator = validators.StringValidator()
        not_req_string_validator = validators.StringValidator(required=False)
        dict_validator = validators.DictValidator({
            'req': req_string_validator,
            'opt': not_req_string_validator,
        })

# Path: libcloud_rest/api/validators.py
# class BaseValidator(object):
# class NumericValidator(BaseValidator):
# class IntegerValidator(NumericValidator):
# class FloatValidator(NumericValidator):
# class StringValidator(BaseValidator):
# class BooleanValidator(BaseValidator):
# class NoneValidator(BaseValidator):
# class ConstValidator(BaseValidator):
# class DictValidator(BaseValidator):
# class ChoicesValidator(BaseValidator):
# class TypeValidator(BaseValidator):
#     def __init__(self, *args, **kwargs):
#     def configure(self, args, kwargs):
#     def _get_name(self):
#     def _set_name(self, new_name):
#     def __call__(self, data):
#     def _validate(self):
#     def _check_data(self):
#     def configure(self, args, kwargs):
#     def _check_data(self):
#     def _check_data(self):
#     def _check_data(self):
#     def _check_data(self):
#     def configure(self, args, kwargs):
#     def _check_data(self):
#     def configure(self, args, kwargs):
#     def _check_data(self):
#     def configure(self, args, kwargs):
#     def _check_data(self):
#     def configure(self, args, kwargs):
#     def _check_data(self):


# Path: tests/test_validators.py
import unittest2
from libcloud_rest.api import validators
from libcloud_rest.errors import ValidationError, MissingArguments,\
    UnknownArgument

        invalid_integer = '12.3'
        self.assertTrue(integer_validator(valid_integer))
        self.assertTrue(integer_validator(valid_integer2))
        self.assertRaises(ValidationError, integer_validator, invalid_integer)
        #test max and min
        max_int_validator = validators.IntegerValidator(max=100, min=0)
        valid_integer = 50
        invalid_integer = -1
        invalid_integer2 = 101
        self.assertTrue(max_int_validator(valid_integer))
        self.assertRaises(ValidationError, max_int_validator, invalid_integer)
        self.assertRaises(ValidationError, max_int_validator, invalid_integer2)

    def test_dict(self):
        dict_validator = validators.DictValidator(
            {'arg1': validators.StringValidator()})
        valid_dict = {'arg1': 'str'}
        invalid_dict = {'arg1': 123}
        invalid_dict2 = {'abc': 'str'}
        self.assertTrue(dict_validator(valid_dict))
        self.assertRaises(ValidationError, dict_validator, invalid_dict)
        self.assertRaises(ValidationError, dict_validator, invalid_dict2)

    def test_required(self):
        req_string_validator = validators.StringValidator()
        not_req_string_validator = validators.StringValidator(required=False)
        dict_validator = validators.DictValidator({
            'req': req_string_validator,
            'opt': not_req_string_validator,
        })

        valid_dict = {'req': 'abc'}