Skip to content

Commit

Permalink
Merge pull request #71 from lingfish/master
Browse files Browse the repository at this point in the history
ValidatorSQL class doesn't handle/pass allow_unknown
  • Loading branch information
amleczko committed Oct 2, 2015
2 parents 68f8c51 + 98f97ce commit 3631709
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
25 changes: 25 additions & 0 deletions eve_sqlalchemy/tests/test_validation_allow_unknown.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# -*- coding: utf-8 -*-

import eve_sqlalchemy.validation
from eve_sqlalchemy.tests.test_settings_sql import DOMAIN
from eve.utils import config

import unittest


class TestValidator(unittest.TestCase):
def setUp(self):
schemas = {
'mock_string': {
'type': 'string',
},
}
# This is usually set in a users' app
DOMAIN['people'].update({
'allow_unknown': True,
})
config.DOMAIN = DOMAIN
self.validator = eve_sqlalchemy.validation.ValidatorSQL(schemas, resource='people')

def test_allow_unknown_true(self):
self.assertTrue(self.validator.allow_unknown)
2 changes: 2 additions & 0 deletions eve_sqlalchemy/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ def __init__(self, schema, resource=None, allow_unknown=False):
super(ValidatorSQL, self).__init__(schema,
transparent_schema_rules=True,
allow_unknown=False)
if resource:
self.allow_unknown = config.DOMAIN[resource]['allow_unknown']

def validate_update(self, document, _id, original_document=None):
self._id = _id
Expand Down

0 comments on commit 3631709

Please sign in to comment.