Esempio n. 1
0
class TestValidator(TestCase):

    def setUp(self):
        from jsonalchemy.validator import Validator
        self.validator = Validator()

    def tearDown(self):
        del self.validator

    def test_objectid(self):
        """Objectid type validation"""
        self.validator._validate_type_objectid(
            '_id', 'abcde12345fabcd67890efab')
        self.assertEqual(self.validator.errors, {})
        self.validator._errors = {}
        self.validator._validate_type_objectid(
            '_id', 'abcde-12345-fabcd-67890e')
        self.assertEqual(self.validator.errors,
                         {'_id': 'must be of ObjectId type'})

    def test_uuid(self):
        """Objectid type validation"""
        _uuid = str(uuid.uuid4())
        self.validator._validate_type_uuid(
            '_id', _uuid)
        self.assertEqual(self.validator.errors, {})
        self.validator._errors = {}
        self.validator._validate_type_uuid(
            '_id', _uuid.replace('-', '_'))
        self.assertEqual(self.validator.errors,
                         {'_id': 'must be of UUID type'})
Esempio n. 2
0
class TestValidator(TestCase):
    def setUp(self):
        from jsonalchemy.validator import Validator
        self.validator = Validator()

    def tearDown(self):
        del self.validator

    def test_objectid(self):
        """Objectid type validation"""
        self.validator._validate_type_objectid('_id',
                                               'abcde12345fabcd67890efab')
        self.assertEqual(self.validator.errors, {})
        self.validator._errors = {}
        self.validator._validate_type_objectid('_id',
                                               'abcde-12345-fabcd-67890e')
        self.assertEqual(self.validator.errors,
                         {'_id': 'must be of ObjectId type'})

    def test_uuid(self):
        """Objectid type validation"""
        _uuid = str(uuid.uuid4())
        self.validator._validate_type_uuid('_id', _uuid)
        self.assertEqual(self.validator.errors, {})
        self.validator._errors = {}
        self.validator._validate_type_uuid('_id', _uuid.replace('-', '_'))
        self.assertEqual(self.validator.errors,
                         {'_id': 'must be of UUID type'})
Esempio n. 3
0
 def setUp(self):
     from jsonalchemy.validator import Validator
     self.validator = Validator()
Esempio n. 4
0
 def setUp(self):
     from jsonalchemy.validator import Validator
     self.validator = Validator()