# 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

    def test_const(self):
        const_validator = validators.ConstValidator({'a': 1})
        valid_data = {'a': 1}
        invalid_data = {'a': '1'}
        self.assertTrue(const_validator(valid_data))
        self.assertRaises(ValidationError, const_validator, invalid_data)

    def test_name(self):
        int_validator = validators.IntegerValidator(name='test')
        invalid_data = 'abc'
        self.assertRaisesRegexp(ValidationError, 'test.*',
                                int_validator, invalid_data)
        dict_validator = validators.DictValidator({
            'test_name': validators.ConstValidator('333')
        })
        self.assertRaisesRegexp(ValidationError, 'test_name .*',
                                dict_validator, {})
        str_validator = validators.StringValidator()
        self.assertRaisesRegexp(ValidationError,
                                '%s .*' % (str_validator.default_name),
                                str_validator, {})

    def test_choices(self):
        choices_valid = validators.ChoicesValidator(['abc', 'cd', 123])
        self.assertTrue(choices_valid('abc'))
        self.assertRaises(ValidationError, choices_valid, 'ab')
        self.assertRaises(TypeError, validators.ChoicesValidator, 123)

    def test_type(self):

# 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


    def test_const(self):
        const_validator = validators.ConstValidator({'a': 1})
        valid_data = {'a': 1}
        invalid_data = {'a': '1'}
        self.assertTrue(const_validator(valid_data))
        self.assertRaises(ValidationError, const_validator, invalid_data)

    def test_name(self):
        int_validator = validators.IntegerValidator(name='test')
        invalid_data = 'abc'
        self.assertRaisesRegexp(ValidationError, 'test.*',
                                int_validator, invalid_data)
        dict_validator = validators.DictValidator({
            'test_name': validators.ConstValidator('333')
        })
        self.assertRaisesRegexp(ValidationError, 'test_name .*',
                                dict_validator, {})
        str_validator = validators.StringValidator()
        self.assertRaisesRegexp(ValidationError,
                                '%s .*' % (str_validator.default_name),
                                str_validator, {})

    def test_choices(self):
        choices_valid = validators.ChoicesValidator(['abc', 'cd', 123])
        self.assertTrue(choices_valid('abc'))
        self.assertRaises(ValidationError, choices_valid, 'ab')
        self.assertRaises(TypeError, validators.ChoicesValidator, 123)

    def test_type(self):

        type_validator = validators.TypeValidator(int)