mirror of
https://github.com/bigchaindb/bigchaindb.git
synced 2024-10-13 13:34:05 +00:00
Removed drop_schema_description() & its test
This commit is contained in:
parent
6291afd0f7
commit
e86fa1f1bb
@ -13,24 +13,11 @@ from bigchaindb.common.exceptions import SchemaValidationError
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def drop_schema_descriptions(node):
|
||||
""" Drop descriptions from schema, since they clutter log output """
|
||||
if 'description' in node:
|
||||
del node['description']
|
||||
for n in node.get('properties', {}).values():
|
||||
drop_schema_descriptions(n)
|
||||
for n in node.get('definitions', {}).values():
|
||||
drop_schema_descriptions(n)
|
||||
for n in node.get('anyOf', []):
|
||||
drop_schema_descriptions(n)
|
||||
|
||||
|
||||
def _load_schema(name):
|
||||
""" Load a schema from disk """
|
||||
path = os.path.join(os.path.dirname(__file__), name + '.yaml')
|
||||
with open(path) as handle:
|
||||
schema = yaml.safe_load(handle)
|
||||
drop_schema_descriptions(schema)
|
||||
fast_schema = rapidjson_schema.loads(rapidjson.dumps(schema))
|
||||
return path, (schema, fast_schema)
|
||||
|
||||
|
@ -11,7 +11,7 @@ from pytest import raises
|
||||
|
||||
from bigchaindb.common.exceptions import SchemaValidationError
|
||||
from bigchaindb.common.schema import (
|
||||
TX_SCHEMA_COMMON, VOTE_SCHEMA, drop_schema_descriptions,
|
||||
TX_SCHEMA_COMMON, VOTE_SCHEMA,
|
||||
validate_transaction_schema, validate_vote_schema)
|
||||
|
||||
SUPPORTED_CRYPTOCONDITION_TYPES = ('threshold-sha-256', 'ed25519-sha-256')
|
||||
@ -46,49 +46,6 @@ def test_vote_schema_additionalproperties():
|
||||
_test_additionalproperties(VOTE_SCHEMA)
|
||||
|
||||
|
||||
def test_drop_descriptions():
|
||||
node = {
|
||||
'description': 'abc',
|
||||
'properties': {
|
||||
'description': {
|
||||
'description': ('The property named "description" should stay'
|
||||
'but description meta field goes'),
|
||||
},
|
||||
'properties': {
|
||||
'description': 'this must go'
|
||||
},
|
||||
'any': {
|
||||
'anyOf': [
|
||||
{
|
||||
'description': 'must go'
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
'definitions': {
|
||||
'wat': {
|
||||
'description': 'go'
|
||||
}
|
||||
}
|
||||
}
|
||||
expected = {
|
||||
'properties': {
|
||||
'description': {},
|
||||
'properties': {},
|
||||
'any': {
|
||||
'anyOf': [
|
||||
{}
|
||||
]
|
||||
}
|
||||
},
|
||||
'definitions': {
|
||||
'wat': {},
|
||||
}
|
||||
}
|
||||
drop_schema_descriptions(node)
|
||||
assert node == expected
|
||||
|
||||
|
||||
################################################################################
|
||||
# Test call transaction schema
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user